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

Merged from McMasterReports branch

This commit is contained in:
azammitdcarf
2010-01-14 07:45:37 +00:00
parent 18dbb16138
commit d1b139d315
1884 changed files with 555891 additions and 364768 deletions

View File

@@ -1,96 +1,101 @@
<?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: COPYRIGHT.php 4381 2008-02-29 22:51:41Z c_schmitz $
*/
// no direct access
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
?>
LimeSurvey derives from copyrighted works licensed under the GNU General
Public License. This version has been modified pursuant to the
GNU General Public License as of August 5, 2007, 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, including
works copyrighted by any or all of the following, from 2003 through 2007:
Jason Cleeland, Carsten Schmitz, Thibault Le Meur, Josef Prandstetter,
David Olivier, Gustavo San Roman, Sébastien Gaugry, Esteban Adrián Pérez,
Gasper Koren, Yeung Kai Sun, Shawn Wales, Ronald Leenes, Mario Marani,
Darrel O'Pry, Marco Ermini, Patrick McKnight, Chris Wessells, Johannes Kutsam,
Karyl Stein, Arjen Gideonse, Nikolay Tsanov, Thomas Lee, Liang Zhao,
Katarina Pavic, Mikkel Skovgaard Sørensen, Rolf Njor Jensen, Johan Geertsma,
Ronald Leenes, Peter De Berdt, Patrick Drews, Peter Sereinigg,
Artemis Mendrinos, David Selmeczi, Gabriele Carioli, Masaru Ryumae,
Odd-Jarle Kristoffersen, Eirik Sunde, Rosaura Gazzola, Job Vieira Lúcio,
Bogdan Anastasiei, Alexei G. Tchernov, Alexander Shilov, Gasper Koren,
Luis M. Martinez, Juan Rafael Fernández, Jose Luis Ramirez, Bjö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)
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)
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)
<?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: COPYRIGHT.php 5431 2008-08-16 21:05:52Z c_schmitz $
*/
// no direct access
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
?>
LimeSurvey derives from copyrighted works licensed under the GNU General
Public License. This version has been modified pursuant to the
GNU General Public License as of August 5, 2007, 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, including
works copyrighted by any or all of the following, from 2003 through 2007:
Jason Cleeland, Carsten Schmitz, Thibault Le Meur, Josef Prandstetter,
David Olivier, Gustavo San Roman, Sébastien Gaugry, Esteban Adrián Pérez,
Gasper Koren, Yeung Kai Sun, Shawn Wales, Ronald Leenes, Mario Marani,
Darrel O'Pry, Marco Ermini, Patrick McKnight, Chris Wessells, Johannes Kutsam,
Karyl Stein, Arjen Gideonse, Nikolay Tsanov, Thomas Lee, Liang Zhao,
Katarina Pavic, Mikkel Skovgaard Sørensen, Rolf Njor Jensen, Johan Geertsma,
Ronald Leenes, Peter De Berdt, Patrick Drews, Peter Sereinigg,
Artemis Mendrinos, David Selmeczi, Gabriele Carioli, Masaru Ryumae,
Odd-Jarle Kristoffersen, Eirik Sunde, Rosaura Gazzola, Job Vieira Lúcio,
Bogdan Anastasiei, Alexei G. Tchernov, Alexander Shilov, Gasper Koren,
Luis M. Martinez, Juan Rafael Fernández, Jose Luis Ramirez, Bjö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)
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)
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,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 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.
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
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
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
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
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work 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 at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a 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 Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; 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
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code 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.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 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
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the 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.
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
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
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
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.
12. 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 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.
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.
<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 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.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 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.
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
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
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
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
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work 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 at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a 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 Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; 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
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code 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.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 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
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the 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.
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
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
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
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.
12. 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 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.
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.
<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 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,141 +1,141 @@
<?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: access_denied.php 4247 2008-02-16 00:24:07Z lemeur $
*/
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly (access_denied)");}
if (isset($_SESSION['loginID']))
{
$accesssummary = "<br /><strong>".$clang->gT("Access denied!")."</strong><br />\n";
$action=returnglobal('action');
if ( $action == "dumpdb" )
{
$accesssummary .= "<p>".$clang->gT("You are not allowed dump the database!")."</p>";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "dumplabel")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed export a label set!")."</p>";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "edituser")
{
$accesssummary .= $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";
}
elseif($action == "newsurvey")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to create new surveys!")."</p>";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "deletesurvey")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to delete this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "addquestion")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to add new questions for this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "activate")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to activate this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "deactivate")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to deactivate this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "addgroup")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to add a group to this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "ordergroups")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to order groups in this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "editsurvey")
{
$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";
}
elseif($action == "editgroup")
{
$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";
}
elseif($action == "browse_response" || $action == "listcolumn" || $action == "vvexport" || $action == "vvimport")
{
$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";
}
elseif($action == "assessment")
{
$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";
}
elseif($action == "delusergroup")
{
$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";
}
elseif($action == "importsurvey")
{
$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";
}
elseif($action == "importgroup")
{
$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";
}
elseif($action == "importquestion")
{
$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";
}
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>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "FakeGET")
{
$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?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
else
{
$accesssummary .= "<br />".$clang->gT("You are not allowed to perform this operation!")."<br />\n";
if(!empty($sid))
$accesssummary .= "<br /><br /><a href='$scriptname?sid=$sid>".$clang->gT("Continue")."</a><br />&nbsp;\n";
elseif(!empty($ugid))
//elseif(isset($_GET['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";
}
}
?>
<?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: access_denied.php 7140 2009-06-18 06:56:20Z mennodekker $
*/
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly (access_denied)");}
if (isset($_SESSION['loginID']))
{
$accesssummary = "<br /><strong>".$clang->gT("Access denied!")."</strong><br />\n";
$action=returnglobal('action');
if ( $action == "dumpdb" )
{
$accesssummary .= "<p>".$clang->gT("You are not allowed dump the database!")."</p>";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "dumplabel")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed export a label set!")."</p>";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "edituser")
{
$accesssummary .= $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";
}
elseif($action == "newsurvey")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to create new surveys!")."</p>";
$accesssummary .= "<a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "deletesurvey")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to delete this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "addquestion")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to add new questions for this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "activate")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to activate this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "deactivate")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to deactivate this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "addgroup")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to add a group to this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "ordergroups")
{
$accesssummary .= "<p>".$clang->gT("You are not allowed to order groups in this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "editsurvey")
{
$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";
}
elseif($action == "editgroup")
{
$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";
}
elseif($action == "browse_response" || $action == "listcolumn" || $action == "vvexport" || $action == "vvimport")
{
$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";
}
elseif($action == "assessment")
{
$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";
}
elseif($action == "delusergroup")
{
$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";
}
elseif($action == "importsurvey")
{
$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";
}
elseif($action == "importgroup")
{
$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";
}
elseif($action == "importquestion")
{
$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";
}
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>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "FakeGET")
{
$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?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
else
{
$accesssummary .= "<br />".$clang->gT("You are not allowed to perform this operation!")."<br />\n";
if(!empty($sid))
$accesssummary .= "<br /><br /><a href='$scriptname?sid=$sid>".$clang->gT("Continue")."</a><br />&nbsp;\n";
elseif(!empty($ugid))
//elseif(isset($_GET['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";
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,223 +1,330 @@
<?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: assessments.php 5096 2008-06-18 08:28:32Z c_schmitz $
*/
include_once("login_check.php");
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($action)) {$action=returnglobal('action');}
$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();
if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $actsurrows['edit_survey_property']){
if ($action == "assessmentadd") {
$inserttable=$dbprefix."assessments";
$query = $connect->GetInsertSQL($inserttable, array(
'sid' => $surveyid,
'scope' => $_POST['scope'],
'gid' => $_POST['gid'],
'minimum' => $_POST['minimum'],
'maximum' => $_POST['maximum'],
'name' => $_POST['name'],
'message' => $_POST['message'],
'link' => $_POST['link'] ));
$result=$connect->Execute($query) or safe_die("Error inserting<br />$query<br />".$connect->ErrorMsg());
} elseif ($action == "assessmentupdate") {
$query = "UPDATE {$dbprefix}assessments
SET scope='".db_quote($_POST['scope'])."',
gid=".sanitize_int($_POST['gid']).",
minimum='".sanitize_int($_POST['minimum'])."',
maximum='".sanitize_int($_POST['maximum'])."',
name='".db_quote($_POST['name'])."',
message='".db_quote($_POST['message'])."',
link='".db_quote($_POST['link'])."'
WHERE 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= "<table width='100%' border='0' >\n"
. "\t<tr>\n"
. "\t\t<td>\n"
. "\t\t\t<table class='menubar'>\n"
. "\t\t\t<tr>\n"
. "\t\t\t\t<td colspan='2' height='8'>\n"
. "\t\t\t\t\t<strong>".$clang->gT("Assessments")."</strong></td></tr>\n";
$assessmentsoutput.= "\t<tr >\n"
. "\t\t<td>\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='' align='left' /></a>\n"
. "\t\t\t<img src='$imagefiles/blank.gif' alt='' width='11' border='0' hspace='0' align='left' />\n"
. "\t\t\t<img src='$imagefiles/seperator.gif' alt='' border='0' hspace='0' align='left' />\n"
. "\t\t</td>\n"
. "\t</tr>\n";
$assessmentsoutput.= "</table>";
if ($surveyid == "") {
$assessmentsoutput.= $clang->gT("No SID Provided");
exit;
}
$assessments=getAssessments($surveyid);
//$assessmentsoutput.= "<pre>";print_r($assessments);echo "</pre>";
$groups=getGroups($surveyid);
$groupselect="<select name='gid'>\n";
foreach($groups as $group) {
$groupselect.="<option value='".$group['gid']."'>".$group['group_name']."</option>\n";
}
$groupselect .="</select>\n";
$headings=array($clang->gT("Scope"), $clang->gT("Group"), $clang->gT("Minimum"), $clang->gT("Maximum"), $clang->gT("Heading"), $clang->gT("Message"), $clang->gT("URL"));
$inputs=array("<select name='scope'><option value='T'>".$clang->gT("Total")."</option><option value='G'>".$clang->gT("Group")."</option></select>",
$groupselect,
"<input type='text' name='minimum' />",
"<input type='text' name='maximum' />",
"<input type='text' name='name' size='80'/>",
"<textarea name='message' rows='10' cols='80'></textarea >",
"<input type='text' name='link' size='80' />");
$actiontitle=$clang->gT("Add");
$actionvalue="assessmentadd";
$thisid="";
if ($action == "assessmentedit") {
$query = "SELECT * FROM {$dbprefix}assessments WHERE id=".sanitize_int($_POST['id']);
$results = db_execute_assoc($query);
while($row=$results->FetchRow()) {
$editdata=$row;
}
$scopeselect = "<select name='scope'><option ";
if ($editdata['scope'] == "T") {$scopeselect .= "selected='selected' ";}
$scopeselect .= "value='T'>".$clang->gT("Total")."</option><option value='G'";
if ($editdata['scope'] == "G") {$scopeselect .= " selected='selected'";}
$scopeselect .= ">".$clang->gT("Group")."</option></select>";
$groupselect=str_replace("'".$editdata['gid']."'", "'".$editdata['gid']."' selected", $groupselect);
$inputs=array($scopeselect,
$groupselect,
"<input type='text' name='minimum' value='".$editdata['minimum']."' />",
"<input type='text' name='maximum' value='".$editdata['maximum']."' />",
"<input type='text' name='name' size='80' value='".htmlentities(stripslashes($editdata['name']), ENT_QUOTES,'UTF-8')."'/>",
"<textarea name='message' rows='10' cols='80'>".htmlentities(stripslashes($editdata['message']), ENT_QUOTES,'UTF-8')."</textarea>",
"<input type='text' name='link' size='80' value='".$editdata['link']."' />");
$actiontitle=$clang->gT("Edit");
$actionvalue="assessmentupdate";
$thisid=$editdata['id'];
}
//$assessmentsoutput.= "<pre>"; print_r($edits); $assessmentsoutput.= "</pre>";
//PRESENT THE PAGE
$assessmentsoutput.= "<br /><table align='center' width='90%'>
<tr><td colspan='12'>".$clang->gT("If you create any assessments in this page, for the currently selected survey, the assessment will be performed at the end of the survey after submission")."</th></tr>"
."<tr><th>ID</th><th>SID</th>\n";
foreach ($headings as $head) {
$assessmentsoutput.= "<th>$head</th>\n";
}
$assessmentsoutput.= "<th>".$clang->gT("Actions")."</th>";
$assessmentsoutput.= "</tr>\n";
$flipflop=true;
foreach($assessments as $assess) {
$flipflop=!$flipflop;
if ($flipflop==true){$assessmentsoutput.= "<tr class='oddrow'>\n";}
else {$assessmentsoutput.= "<tr class='evenrow'>\n";}
$assessmentsoutput.= "<td>".$assess['id']."</td>\n";
$assessmentsoutput.= "<td>".$assess['sid']."</td>\n";
if ($assess['scope'] == "T") { $assessmentsoutput.= "<td>".$clang->gT("Total")."</td>\n"; }
else {$assessmentsoutput.= "<td>".$clang->gT("Group")."</td>\n"; }
$assessmentsoutput.= "<td>".$groups[$assess['gid']]['group_name']." (".$assess['gid'].")</td>\n";
$assessmentsoutput.= "<td>".$assess['minimum']."</td>\n";
$assessmentsoutput.= "<td>".$assess['maximum']."</td>\n";
$assessmentsoutput.= "<td>".stripslashes($assess['name'])."</td>\n";
$assessmentsoutput.= "<td>".stripslashes($assess['message'])."</td>\n";
$assessmentsoutput.= "<td>".stripslashes($assess['link'])."</td>\n";
$assessmentsoutput.= "<td>
<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.= "<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]."</td></tr>\n";
$i++;
}
$assessmentsoutput.= "<tr><th colspan='2' align='center'><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"
."</th></tr>\n"
."</table></form></td></tr></table>\n";
}
else
{
$action = "assessment";
include("access_denied.php");
include("admin.php");
}
function getAssessments($surveyid) {
global $dbprefix, $connect;
$query = "SELECT id, sid, scope, gid, minimum, maximum, name, message, link
FROM ".db_table_name('assessments')."
WHERE sid='$surveyid'
ORDER BY scope, gid";
$result=db_execute_assoc($query) or safe_die("Error getting assessments<br />$query<br />".$connect->ErrorMsg());
$output=array();
while($row=$result->FetchRow()) {
$output[]=$row;
}
return $output;
}
function getGroups($surveyid) {
global $dbprefix, $connect;
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$query = "SELECT gid, group_name
FROM ".db_table_name('groups')."
WHERE sid='$surveyid' and language='$baselang'
ORDER BY group_order";
$result = db_execute_assoc($query) or safe_die("Error getting groups<br />$query<br />".$connect->ErrorMsg());
$output=array();
while($row=$result->FetchRow()) {
$output[$row['gid']]=$row;
}
return $output;
}
?>
<?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: assessments.php 7428 2009-08-10 10:26:46Z c_schmitz $
*/
include_once("login_check.php");
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($action)) {$action=returnglobal('action');}
$surveyinfo=getSurveyInfo($surveyid);
$js_adminheader_includes[]= $homeurl.'/scripts/assessments.js';
$js_adminheader_includes[]= $rooturl.'/scripts/jquery/jquery-ui.js';
// . "<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);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($assessmentlangs,$baselang); // makes an array with ALL the languages supported by the survey -> $assessmentlangs
if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $actsurrows['edit_survey_property']){
if ($action == "assessmentadd") {
$inserttable=$dbprefix."assessments";
$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>';
}
$assessmentsoutput.= "\t\t</div>\n"
. "\t</div>\n"
. "</div>\n";
$assessmentsoutput .= "<p style='margin:0;font-size:1px;line-height:1px;height:1px;'>&nbsp;</p>"; //CSS Firefox 2 transition fix
if ($surveyid == "") {
$assessmentsoutput.= $clang->gT("No SID Provided");
exit;
}
$assessments=getAssessments($surveyid);
//$assessmentsoutput.= "<pre>";print_r($assessments);echo "</pre>";
$groups=getGroups($surveyid);
$groupselect="<select name='gid' id='newgroupselect'>\n";
foreach($groups as $group) {
$groupselect.="<option value='".$group['gid']."'>".$group['group_name']."</option>\n";
}
$groupselect .="</select>\n";
$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");
$actionvalue="assessmentadd";
$thisid="";
if ($action == "assessmentedit") {
$query = "SELECT * FROM {$dbprefix}assessments WHERE id=".sanitize_int($_POST['id'])." and language='$baselang'";
$results = db_execute_assoc($query);
while($row=$results->FetchRow()) {
$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);
$inputs=array($scopeselect,
$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";
$thisid=$editdata['id'];
}
//$assessmentsoutput.= "<pre>"; print_r($edits); $assessmentsoutput.= "</pre>";
//PRESENT THE PAGE
$assessmentsoutput.= "<br /><table align='center' width='90%'>
<tr><th colspan='12'>".$clang->gT("Assessment rules")."</th></tr>"
."<tr><th>".$clang->gT("ID")."</th><th>".$clang->gT("SID")."</th>\n";
foreach ($headings as $head) {
$assessmentsoutput.= "<th>$head</th>\n";
}
$assessmentsoutput.= "<th>".$clang->gT("Title")."</th><th>".$clang->gT("Message")."</th><th>".$clang->gT("Actions")."</th>";
$assessmentsoutput.= "</tr>\n";
$flipflop=true;
foreach($assessments as $assess) {
$flipflop=!$flipflop;
if ($flipflop==true){$assessmentsoutput.= "<tr class='oddrow'>\n";}
else {$assessmentsoutput.= "<tr class='evenrow'>\n";}
$assessmentsoutput.= "<td>".$assess['id']."</td>\n";
$assessmentsoutput.= "<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['maximum']."</td>\n";
$assessmentsoutput.= "<td>".stripslashes($assess['name'])."</td>\n";
$assessmentsoutput.= "<td>".strip_tags(strip_javascript($assess['message']))."</td>\n";
$assessmentsoutput.= "<td>
<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>";
//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);
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=$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) {
global $dbprefix, $connect, $baselang;
$query = "SELECT id, sid, scope, gid, minimum, maximum, name, message
FROM ".db_table_name('assessments')."
WHERE sid='$surveyid' and language='$baselang'
ORDER BY scope, gid";
$result=db_execute_assoc($query) or safe_die("Error getting assessments<br />$query<br />".$connect->ErrorMsg());
$output=array();
while($row=$result->FetchRow()) {
$output[]=$row;
}
return $output;
}
function getGroups($surveyid) {
global $dbprefix, $connect;
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$query = "SELECT gid, group_name
FROM ".db_table_name('groups')."
WHERE sid='$surveyid' and language='$baselang'
ORDER BY group_order";
$result = db_execute_assoc($query) or safe_die("Error getting groups<br />$query<br />".$connect->ErrorMsg());
$output=array();
while($row=$result->FetchRow()) {
$output[$row['gid']]=$row;
}
return $output;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,7 @@
If you want to distribute this code, please do it as a link to:
http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
*/
@ini_set('zend.ze1_compatibility_mode', '0');
define('DOMXML_LOAD_PARSING',0);
define('DOMXML_LOAD_VALIDATING',1);
define('DOMXML_LOAD_RECOVERING',2);
@@ -79,7 +79,7 @@ function xmldocfile($filename) {return domxml_open_file($filename);}
function xpath_eval($xpath_context,$eval_str,$contextnode=null) {return $xpath_context->xpath_eval($eval_str,$contextnode);}
function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document);}
function xpath_register_ns($xpath_context,$prefix,$namespaceURI) {return $xpath_context->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
function _entityDecode($text) {return html_entity_decode_php4(strtr($text,array('&apos;'=>'\'')),ENT_QUOTES,'UTF-8');}
function _entityDecode($text) {return html_entity_decode(strtr($text,array('&apos;'=>'\'')),ENT_QUOTES,'UTF-8');}
function _error_report($error) {return array('errormessage'=>$error->message,'nodename'=>'','line'=>$error->line,'col'=>$error->column)+($error->file==''?array():array('directory'=>dirname($error->file),'file'=>basename($error->file)));}
class php4DOMAttr extends php4DOMNode

View File

@@ -3,7 +3,7 @@
/*******************************************************************************
*
* SHA256 static class for PHP4
* SHA256 static class for PHP
* implemented by feyd _at_ devnetwork .dot. net
* specification from http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
*
@@ -15,10 +15,10 @@
*----- Version 1.0.1 ----------------------------------------------------------
*
* Syntax:
* string SHA256::hash( string message[, string format ])
* string SHA256::hashing( string message[, string format ])
*
* Description:
* SHA256::hash() is a static function that must be called with `message`
* SHA256::hashing() is a static function that must be called with `message`
* and optionally `format`. Possible values for `format` are:
* 'bin' binary string output
* 'hex' default; hexidecimal string output (lower case)
@@ -26,7 +26,7 @@
* Failures return FALSE.
*
* Usage:
* $hash = SHA256::hash('string to hash');
* $hash = SHA256::hashing('string to hash');
*
******************************************************************************/
@@ -136,7 +136,7 @@ class SHA256Data extends hashData
// static class. Access via SHA256::hash()
class SHA256 extends hash
{
function hash($str, $mode = 'hex')
static function hashing($str, $mode = 'hex')
{
static $modes = array( 'hex', 'bin', 'bit' );
$ret = false;
@@ -147,7 +147,7 @@ class SHA256 extends hash
}
else
{
$data =& new SHA256Data($str);
$data = new SHA256Data($str);
SHA256::compute($data);
@@ -171,7 +171,7 @@ class SHA256 extends hash
// begin internal functions
// 32-bit summation
function sum()
static function sum()
{
$T = 0;
for($x = 0, $y = func_num_args(); $x < $y; $x++)
@@ -202,7 +202,7 @@ class SHA256 extends hash
// compute the hash
function compute(&$hashData)
static function compute(&$hashData)
{
static $vars = 'abcdefgh';
static $K = null;
@@ -292,7 +292,7 @@ class SHA256 extends hash
// set up the display of the hash in hex.
function hashHex(&$hashData)
static function hashHex(&$hashData)
{
$str = '';
@@ -385,7 +385,7 @@ function test1()
echo 'Testing ' . var_export($str,true) . "\n";
list($s1,$s2) = explode(' ', microtime());
for($x = 0; $x < $it; $x++)
$data =& new SHA256Data($str);
$data = new SHA256Data($str);
list($e1,$e2) = explode(' ', microtime());
echo hexerize($data->chunks);
echo hexerize($data->hash);

View File

@@ -305,7 +305,7 @@ class OLE extends PEAR
* @param string $ascii The ASCII string to transform
* @return string The string in Unicode
*/
function Asc2Ucs($ascii)
static function Asc2Ucs($ascii)
{
$rawname = '';
for ($i = 0; $i < strlen($ascii); $i++) {
@@ -323,7 +323,7 @@ class OLE extends PEAR
* @param integer $date A timestamp
* @return string The string for the OLE container
*/
function LocalDate2OLE($date = null)
static function LocalDate2OLE($date = null)
{
if (!isset($date)) {
return "\x00\x00\x00\x00\x00\x00\x00\x00";
@@ -370,7 +370,7 @@ class OLE extends PEAR
* @param integer $string A binary string with the encoded date
* @return string The timestamp corresponding to the string
*/
function OLE2LocalDate($string)
static function OLE2LocalDate($string)
{
if (strlen($string) != 8) {
return new PEAR_Error("Expecting 8 byte string");

View File

@@ -263,10 +263,10 @@ class PEAR
* $code is an integer and $obj->getCode() == $code
* @access public
* @return bool true if parameter is an error
*/
*/
function isError($data, $code = null)
{
if (is_a($data, 'PEAR_Error')) {
if ($data instanceof PEAR_Error) {
if (is_null($code)) {
return true;
} elseif (is_string($code)) {
@@ -554,10 +554,10 @@ class PEAR
$ec = 'PEAR_Error';
}
if ($skipmsg) {
$a = &new $ec($code, $mode, $options, $userinfo);
$a = new $ec($code, $mode, $options, $userinfo);
return $a;
} else {
$a = &new $ec($message, $code, $mode, $options, $userinfo);
$a = new $ec($message, $code, $mode, $options, $userinfo);
return $a;
}
}

View File

@@ -1207,7 +1207,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
default:
// if it's a reference
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
!ereg("[0-9]",$this->_lookahead) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.') and
($this->_lookahead != '!'))
{
@@ -1215,39 +1215,39 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)
elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return $token;
}
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1)
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return $token;
}
// if it's a range (A1:A2)
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead))
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// if it's a range (A1..A2)
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead))
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2
elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead))
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead))
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
@@ -1259,12 +1259,12 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
return $token;
}
// If it's a string (of maximum 255 characters)
elseif (ereg("^\"[^\"]{0,255}\"$",$token))
elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token))
{
return $token;
}
// if it's a function call
elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "("))
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
{
return $token;
}
@@ -1364,7 +1364,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
function _expression()
{
// If it's a string return a string node
if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) {
if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) {
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
@@ -1522,7 +1522,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
return $result;
}
// if it's a function call
elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token))
{
$result = $this->_func();
return $result;

View File

@@ -184,7 +184,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
$this->Spreadsheet_Excel_Writer_BIFFwriter();
$this->_filename = $filename;
$this->_parser =& new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version);
$this->_parser = new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version);
$this->_1904 = 0;
$this->_activesheet = 0;
$this->_firstsheet = 0;
@@ -193,7 +193,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
$this->_fileclosed = 0;
$this->_biffsize = 0;
$this->_sheetname = 'Sheet';
$this->_tmp_format =& new Spreadsheet_Excel_Writer_Format($this->_BIFF_version);
$this->_tmp_format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version);
$this->_worksheets = array();
$this->_sheetnames = array();
$this->_formats = array();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,190 @@
<?php
/**
* @file CAS/PGTStorage/pgt-db.php
* Basic class for PGT database storage
*/
/**
* @class PGTStorageDB
* The PGTStorageDB class is a class for PGT database storage. An instance of
* this class is returned by CASClient::SetPGTStorageDB().
*
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
*
* @ingroup internalPGTStorageDB
*/
class PGTStorageDB extends PGTStorage
{
/**
* @addtogroup internalPGTStorageDB
* @{
*/
/**
* a string representing a PEAR DB URL to connect to the database. Written by
* PGTStorageDB::PGTStorageDB(), read by getURL().
*
* @hideinitializer
* @private
*/
var $_url='';
/**
* This method returns the PEAR DB URL to use to connect to the database.
*
* @return a PEAR DB URL
*
* @private
*/
function getURL()
{
return $this->_url;
}
/**
* The handle of the connection to the database where PGT's are stored. Written by
* PGTStorageDB::init(), read by getLink().
*
* @hideinitializer
* @private
*/
var $_link = null;
/**
* This method returns the handle of the connection to the database where PGT's are
* stored.
*
* @return a handle of connection.
*
* @private
*/
function getLink()
{
return $this->_link;
}
/**
* The name of the table where PGT's are stored. Written by
* PGTStorageDB::PGTStorageDB(), read by getTable().
*
* @hideinitializer
* @private
*/
var $_table = '';
/**
* This method returns the name of the table where PGT's are stored.
*
* @return the name of a table.
*
* @private
*/
function getTable()
{
return $this->_table;
}
// ########################################################################
// DEBUGGING
// ########################################################################
/**
* This method returns an informational string giving the type of storage
* used by the object (used for debugging purposes).
*
* @return an informational string.
* @public
*/
function getStorageType()
{
return "database";
}
/**
* This method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes).
*
* @public
*/
function getStorageInfo()
{
return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
}
// ########################################################################
// CONSTRUCTOR
// ########################################################################
/**
* The class constructor, called by CASClient::SetPGTStorageDB().
*
* @param $cas_parent the CASClient instance that creates the object.
* @param $user the user to access the data with
* @param $password the user's password
* @param $database_type the type of the database hosting the data
* @param $hostname the server hosting the database
* @param $port the port the server is listening on
* @param $database the name of the database
* @param $table the name of the table storing the data
*
* @public
*/
function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
{
phpCAS::traceBegin();
// call the ancestor's constructor
$this->PGTStorage($cas_parent);
if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
// build and store the PEAR DB URL
$this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
// XXX should use setURL and setTable
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();
}
/** @} */
}
?>

View File

@@ -0,0 +1,249 @@
<?php
/**
* @file CAS/PGTStorage/pgt-file.php
* Basic class for PGT file storage
*/
/**
* @class PGTStorageFile
* The PGTStorageFile class is a class for PGT file storage. An instance of
* this class is returned by CASClient::SetPGTStorageFile().
*
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
*
* @ingroup internalPGTStorageFile
*/
class PGTStorageFile extends PGTStorage
{
/**
* @addtogroup internalPGTStorageFile
* @{
*/
/**
* a string telling where PGT's should be stored on the filesystem. Written by
* PGTStorageFile::PGTStorageFile(), read by getPath().
*
* @private
*/
var $_path;
/**
* This method returns the name of the directory where PGT's should be stored
* on the filesystem.
*
* @return the name of a directory (with leading and trailing '/')
*
* @private
*/
function getPath()
{
return $this->_path;
}
/**
* a string telling the format to use to store PGT's (plain or xml). Written by
* PGTStorageFile::PGTStorageFile(), read by getFormat().
*
* @private
*/
var $_format;
/**
* 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).
*
* @private
*/
function getFormat()
{
return $this->_format;
}
// ########################################################################
// DEBUGGING
// ########################################################################
/**
* This method returns an informational string giving the type of storage
* used by the object (used for debugging purposes).
*
* @return an informational string.
* @public
*/
function getStorageType()
{
return "file";
}
/**
* This method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes).
*
* @return an informational string.
* @public
*/
function getStorageInfo()
{
return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
}
// ########################################################################
// CONSTRUCTOR
// ########################################################################
/**
* The class constructor, called by CASClient::SetPGTStorageFile().
*
* @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 $path the path where the PGT's should be stored
*
* @public
*/
function PGTStorageFile($cas_parent,$format,$path)
{
phpCAS::traceBegin();
// call the ancestor's constructor
$this->PGTStorage($cas_parent);
if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
// check that the path is an absolute path
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 '/')
$path = preg_replace('|[/]*$|','/',$path);
$path = preg_replace('|^[/]*|','/',$path);
}
$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
// ########################################################################
/**
* 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();
phpCAS::traceEnd();
}
// ########################################################################
// PGT I/O
// ########################################################################
/**
* This method returns the filename corresponding to a PGT Iou.
*
* @param $pgt_iou the PGT iou.
*
* @return a filename
* @private
*/
function getPGTIouFilename($pgt_iou)
{
phpCAS::traceBegin();
$filename = $this->getPath().$pgt_iou.'.'.$this->getFormat();
phpCAS::traceEnd($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
* 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

@@ -0,0 +1,188 @@
<?php
/**
* @file CAS/PGTStorage/pgt-main.php
* Basic class for PGT storage
*/
/**
* @class PGTStorage
* The PGTStorage class is a generic class for PGT storage. This class should
* not be instanciated itself but inherited by specific PGT storage classes.
*
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
*
* @ingroup internalPGTStorage
*/
class PGTStorage
{
/**
* @addtogroup internalPGTStorage
* @{
*/
// ########################################################################
// CONSTRUCTOR
// ########################################################################
/**
* The constructor of the class, should be called only by inherited classes.
*
* @param $cas_parent the CASclient instance that creates the current object.
*
* @protected
*/
function PGTStorage($cas_parent)
{
phpCAS::traceBegin();
if ( !$cas_parent->isProxy() ) {
phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy');
}
phpCAS::traceEnd();
}
// ########################################################################
// DEBUGGING
// ########################################################################
/**
* This virtual method returns an informational string giving the type of storage
* used by the object (used for debugging purposes).
*
* @public
*/
function getStorageType()
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
/**
* This virtual method returns an informational string giving informations on the
* parameters of the storage.(used for debugging purposes).
*
* @public
*/
function getStorageInfo()
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
// ########################################################################
// 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
* PGTStorage::getErrorMessage().
*
* @param $error_message an error message
*
* @protected
* @deprecated not used.
*/
function setErrorMessage($error_message)
{
$this->_error_message = $error_message;
}
/**
* This method returns an error message set by PGTStorage::setErrorMessage().
*
* @return an error message when set by PGTStorage::setErrorMessage(), FALSE
* otherwise.
*
* @public
* @deprecated not used.
*/
function getErrorMessage()
{
return $this->_error_message;
}
// ########################################################################
// INITIALIZATION
// ########################################################################
/**
* a boolean telling if the storage has already been initialized. Written by
* PGTStorage::init(), read by PGTStorage::isInitialized().
*
* @hideinitializer
* @private
*/
var $_initialized = FALSE;
/**
* This method tells if the storage has already been intialized.
*
* @return a boolean
*
* @protected
*/
function isInitialized()
{
return $this->_initialized;
}
/**
* This virtual method initializes the object.
*
* @protected
*/
function init()
{
$this->_initialized = TRUE;
}
// ########################################################################
// PGT I/O
// ########################################################################
/**
* This virtual method stores a PGT and its corresponding PGT Iuo.
* @note Should never be called.
*
* @param $pgt the PGT
* @param $pgt_iou the PGT iou
*
* @protected
*/
function write($pgt,$pgt_iou)
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
/**
* This virtual method reads a PGT corresponding to a PGT Iou and deletes
* the corresponding storage entry.
* @note Should never be called.
*
* @param $pgt_iou the PGT iou
*
* @protected
*/
function read($pgt_iou)
{
phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
}
/** @} */
}
// include specific PGT storage classes
include_once(dirname(__FILE__).'/pgt-file.php');
include_once(dirname(__FILE__).'/pgt-db.php');
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,277 @@
<?php
/**
* @file domxml-php4-php5.php
* Require PHP5, uses built-in DOM extension.
* To be used in PHP4 scripts using DOMXML extension.
* Allows PHP4/DOMXML scripts to run on PHP5/DOM.
* (Requires PHP5/XSL extension for domxml_xslt functions)
*
* Typical use:
* <pre>
* {
* if (version_compare(PHP_VERSION,'5','>='))
* require_once('domxml-php4-to-php5.php');
* }
* </pre>
*
* Version 1.5.5, 2005-01-18, http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
*
* ------------------------------------------------------------------<br>
* Written by Alexandre Alapetite, http://alexandre.alapetite.net/cv/
*
* Copyright 2004, Licence: Creative Commons "Attribution-ShareAlike 2.0 France" BY-SA (FR),
* http://creativecommons.org/licenses/by-sa/2.0/fr/
* http://alexandre.alapetite.net/divers/apropos/#by-sa
* - Attribution. You must give the original author credit
* - 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
* - The French law is authoritative
* - Any of these conditions can be waived if you get permission from Alexandre Alapetite
* - Please send to Alexandre Alapetite the modifications you make,
* 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:
* http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
*/
function domxml_new_doc($version) {return new php4DOMDocument('');}
function domxml_open_file($filename) {return new php4DOMDocument($filename);}
function domxml_open_mem($str)
{
$dom=new php4DOMDocument('');
$dom->myDOMNode->loadXML($str);
return $dom;
}
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);}
class php4DOMAttr extends php4DOMNode
{
function php4DOMAttr($aDOMAttr) {$this->myDOMNode=$aDOMAttr;}
function Name() {return $this->myDOMNode->name;}
function Specified() {return $this->myDOMNode->specified;}
function Value() {return $this->myDOMNode->value;}
}
class php4DOMDocument extends php4DOMNode
{
function php4DOMDocument($filename='')
{
$this->myDOMNode=new DOMDocument();
if ($filename!='') $this->myDOMNode->load($filename);
}
function create_attribute($name,$value)
{
$myAttr=$this->myDOMNode->createAttribute($name);
$myAttr->value=$value;
return new php4DOMAttr($myAttr,$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_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$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 dump_file($filename,$compressionmode=false,$format=false) {return $this->myDOMNode->save($filename);}
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_elements_by_tagname($name)
{
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMElement($node,$this);
$i++;
}
return $nodeSet;
}
function html_dump_mem() {return $this->myDOMNode->saveHTML();}
function root() {return new php4DOMElement($this->myDOMNode->documentElement,$this);}
}
class php4DOMElement extends php4DOMNode
{
function get_attribute($name) {return $this->myDOMNode->getAttribute($name);}
function get_elements_by_tagname($name)
{
$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
$i++;
}
return $nodeSet;
}
function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);}
function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);}
function set_attribute($name,$value) {return $this->myDOMNode->setAttribute($name,$value);}
function tagname() {return $this->myDOMNode->tagName;}
}
class php4DOMNode
{
var $myDOMNode;
var $myOwnerDocument;
function php4DOMNode($aDomNode,$aOwnerDocument)
{
$this->myDOMNode=$aDomNode;
$this->myOwnerDocument=$aOwnerDocument;
}
function __get($name)
{
if ($name=='type') return $this->myDOMNode->nodeType;
elseif ($name=='tagname') return $this->myDOMNode->tagName;
elseif ($name=='content') return $this->myDOMNode->textContent;
else
{
$myErrors=debug_backtrace();
trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
return false;
}
}
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 attributes()
{
$myDOMNodeList=$this->myDOMNode->attributes;
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
$i++;
}
return $nodeSet;
}
function child_nodes()
{
$myDOMNodeList=$this->myDOMNode->childNodes;
$nodeSet=array();
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
$nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
$i++;
}
return $nodeSet;
}
function children() {return $this->child_nodes();}
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 get_content() {return $this->myDOMNode->textContent;}
function has_attributes() {return $this->myDOMNode->hasAttributes();}
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 is_blank_node()
{
$myDOMNodeList=$this->myDOMNode->childNodes;
$i=0;
if (isset($myDOMNodeList))
while ($node=$myDOMNodeList->item($i))
{
if (($node->nodeType==XML_ELEMENT_NODE)||
(($node->nodeType==XML_TEXT_NODE)&&!preg_match('/^([[:cntrl:]]|[[:space:]])*$/',$node->nodeValue)))
return false;
$i++;
}
return true;
}
function last_child() {return new php4DOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);}
function new_child($name,$content)
{
$mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
$mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($content));
$this->myDOMNode->appendChild($mySubNode);
return new php4DOMElement($mySubNode,$this->myOwnerDocument);
}
function next_sibling() {return new php4DOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);}
function node_name() {return $this->myDOMNode->localName;}
function node_type() {return $this->myDOMNode->nodeType;}
function node_value() {return $this->myDOMNode->nodeValue;}
function owner_document() {return $this->myOwnerDocument;}
function parent_node() {return new php4DOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);}
function prefix() {return $this->myDOMNode->prefix;}
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 replace_child($oldnode,$newnode) {return new php4DOMElement($this->myDOMNode->replaceChild($oldnode->myDOMNode,$newnode->myDOMNode),$this->myOwnerDocument);}
function set_content($text)
{
if (($this->myDOMNode->hasChildNodes())&&($this->myDOMNode->firstChild->nodeType==XML_TEXT_NODE))
$this->myDOMNode->removeChild($this->myDOMNode->firstChild);
return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text));
}
}
class php4DOMNodelist
{
var $myDOMNodelist;
var $nodeset;
function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
{
$this->myDOMNodelist=$aDOMNodelist;
$this->nodeset=array();
$i=0;
if (isset($this->myDOMNodelist))
while ($node=$this->myDOMNodelist->item($i))
{
$this->nodeset[]=new php4DOMElement($node,$aOwnerDocument);
$i++;
}
}
}
class php4DOMXPath
{
var $myDOMXPath;
var $myOwnerDocument;
function php4DOMXPath($dom_document)
{
$this->myOwnerDocument=$dom_document;
$this->myDOMXPath=new DOMXPath($dom_document->myDOMNode);
}
function query($eval_str,$contextnode)
{
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);
}
function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
}
if (extension_loaded('xsl'))
{//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_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);}
function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));}
class php4DomXsltStylesheet
{
var $myxsltProcessor;
function php4DomXsltStylesheet($dom_document)
{
$this->myxsltProcessor=new xsltProcessor();
$this->myxsltProcessor->importStyleSheet($dom_document);
}
function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
{
foreach ($xslt_parameters as $param=>$value)
$this->myxsltProcessor->setParameter('',$param,$value);
$myphp4DOMDocument=new php4DOMDocument();
$myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
return $myphp4DOMDocument;
}
function result_dump_file($dom_document,$filename)
{
$html=$dom_document->myDOMNode->saveHTML();
file_put_contents($filename,$html);
return $html;
}
function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();}
}
}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* @file languages/spanish.php
* @author Iván-Benjamín García Torà <ivaniclixx AT gmail DOT com>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'usant servidor',
CAS_STR_AUTHENTICATION_WANTED
=> 'Autentificació CAS necessària!',
CAS_STR_LOGOUT
=> 'Sortida de CAS necessària!',
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.',
CAS_STR_AUTHENTICATION_FAILED
=> 'Autentificació CAS fallida!',
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>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'El servei `<b>%s</b>\' no està disponible (<b>%s</b>).'
);
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* @file languages/english.php
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'using server',
CAS_STR_AUTHENTICATION_WANTED
=> 'CAS Authentication wanted!',
CAS_STR_LOGOUT
=> 'CAS logout wanted!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'You should already have been redirected to the CAS server. Click <a href="%s">here</a> to continue.',
CAS_STR_AUTHENTICATION_FAILED
=> 'CAS Authentication failed!',
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>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'The service `<b>%s</b>\' is not available (<b>%s</b>).'
);
?>

View File

@@ -0,0 +1,28 @@
<?php
/**
* @file languages/english.php
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'utilisant le serveur',
CAS_STR_AUTHENTICATION_WANTED
=> 'Authentication CAS nécessaire&nbsp;!',
CAS_STR_LOGOUT
=> 'Déconnexion demandée&nbsp;!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Vous auriez du etre redirigé(e) vers le serveur CAS. Cliquez <a href="%s">ici</a> pour continuer.',
CAS_STR_AUTHENTICATION_FAILED
=> 'Authentification CAS infructueuse&nbsp;!',
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>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'Le service `<b>%s</b>\' est indisponible (<b>%s</b>)'
);
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* @file languages/german.php
* @author Henrik Genssen <hg at mediafactory.de>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'via Server',
CAS_STR_AUTHENTICATION_WANTED
=> 'CAS Authentifizierung erforderlich!',
CAS_STR_LOGOUT
=> 'CAS Abmeldung!',
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.',
CAS_STR_AUTHENTICATION_FAILED
=> 'CAS Anmeldung fehlgeschlagen!',
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>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'Der Dienst `<b>%s</b>\' ist nicht verf&uuml;gbar (<b>%s</b>).'
);
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* @file languages/greek.php
* @author Vangelis Haniotakis <haniotak at ucnet.uoc.gr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> '÷ñçóéìïðïéåßôáé ï åîõðçñåôçôÞò',
CAS_STR_AUTHENTICATION_WANTED
=> 'Áðáéôåßôáé ç ôáõôïðïßçóç CAS!',
CAS_STR_LOGOUT
=> 'Áðáéôåßôáé ç áðïóýíäåóç áðü CAS!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Èá Ýðñåðå íá åß÷áôå áíáêáôåõèõíèåß óôïí åîõðçñåôçôÞ CAS. ÊÜíôå êëßê <a href="%s">åäþ</a> ãéá íá óõíå÷ßóåôå.',
CAS_STR_AUTHENTICATION_FAILED
=> 'Ç ôáõôïðïßçóç CAS áðÝôõ÷å!',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>Äåí ôáõôïðïéçèÞêáôå.</p><p>Ìðïñåßôå íá îáíáðñïóðáèÞóåôå, êÜíïíôáò êëßê <a href="%s">åäþ</a>.</p><p>Åáí ôï ðñüâëçìá åðéìåßíåé, åëÜôå óå åðáöÞ ìå ôïí <a href="mailto:%s">äéá÷åéñéóôÞ</a>.</p>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'Ç õðçñåóßá `<b>%s</b>\' äåí åßíáé äéáèÝóéìç (<b>%s</b>).'
);
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* @file languages/japanese.php
* @author fnorif (fnorif@yahoo.co.jp)
*
* Now Encoding is EUC-JP and LF
**/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'using server',
CAS_STR_AUTHENTICATION_WANTED
=> 'CASによる認証を行います',
CAS_STR_LOGOUT
=> 'CASからログアウトします!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'CASサーバに行く必要があります。自動的に転送されない場合は <a href="%s">こちら</a> をクリックして続行します。',
CAS_STR_AUTHENTICATION_FAILED
=> 'CASによる認証に失敗しました',
CAS_STR_YOU_WERE_NOT_AUTHENTICATED
=> '<p>認証できませんでした.</p><p>もう一度リクエストを送信する場合は<a href="%s">こちら</a>をクリック.</p><p>問題が解決しない場合は <a href="mailto:%s">このサイトの管理者</a>に問い合わせてください.</p>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'サービス `<b>%s</b>\' は利用できません (<b>%s</b>).'
);
?>

View File

@@ -0,0 +1,24 @@
<?php
/**
* @file languages/languages.php
* Internationalization constants
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
//@{
/**
* a phpCAS string index
*/
define("CAS_STR_USING_SERVER", 1);
define("CAS_STR_AUTHENTICATION_WANTED", 2);
define("CAS_STR_LOGOUT", 3);
define("CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED", 4);
define("CAS_STR_AUTHENTICATION_FAILED", 5);
define("CAS_STR_YOU_WERE_NOT_AUTHENTICATED", 6);
define("CAS_STR_SERVICE_UNAVAILABLE", 7);
//@}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* @file languages/spanish.php
* @author Iván-Benjamín García Torà <ivaniclixx AT gmail DOT com>
* @sa @link internalLang Internationalization @endlink
* @ingroup internalLang
*/
$this->_strings = array(
CAS_STR_USING_SERVER
=> 'usando servidor',
CAS_STR_AUTHENTICATION_WANTED
=> '¡Autentificación CAS necesaria!',
CAS_STR_LOGOUT
=> '¡Salida CAS necesaria!',
CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED
=> 'Ya debería haber sido redireccionado al servidor CAS. Haga click <a href="%s">aquí</a> para continuar.',
CAS_STR_AUTHENTICATION_FAILED
=> '¡Autentificación CAS fallida!',
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>',
CAS_STR_SERVICE_UNAVAILABLE
=> 'El servicio `<b>%s</b>\' no está disponible (<b>%s</b>).'
);
?>

View File

@@ -0,0 +1,36 @@
README
phpCAS - http://www.ja-sig.org/wiki/display/CASC/phpCAS
This software contains a client library for PHP, which can be used to identify
Central Authentication Service (CAS) authenticated users.
Please see the phpCAS website for more information.
http://www.ja-sig.org/wiki/display/CASC/phpCAS
LICENSE
Copyright © 2003-2008, The ESUP-Portail consortium & the JA-SIG Collaborative.
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 the ESUP-Portail consortium & the JA-SIG
Collaborative nor the names of its 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 COPYRIGHT OWNER 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.

View File

@@ -1,273 +1,271 @@
<?php
#
# PHPZip v1.2 by Sext (sext@neud.net) 2002-11-18
# (Changed: 2003-03-01)
#
# Makes zip archive
#
# Based on "Zip file creation class", uses zLib
#
#
# Modified by Jason Cleeland - removed "subdirectory" capacity for LimeSurvey use
class PHPZip
{
function Zip($dir, $zipfilename)
{
if (@function_exists('gzcompress'))
{
$curdir = getcwd();
if (is_array($dir))
{
$filelist = $dir;
}
else
{
$filelist = $this -> GetFileList($dir);
}
if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
else chdir($curdir);
if (count($filelist)>0)
{
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);
$this -> addFile($content, $filename);
}
}
$out = $this -> file();
chdir($curdir);
$fp = fopen($zipfilename, "w");
fwrite($fp, $out, strlen($out));
fclose($fp);
}
return 1;
}
else return 0;
}
function GetFileList($dir)
{
$file=Array();
if (file_exists($dir))
{
$args = func_get_args();
if(isset($args[1])) {$pref = $args[1];} else {$pref="";}
$dh = opendir($dir);
while($files = readdir($dh))
{
if (($files!=".")&&($files!=".."))
{
if (!is_dir($dir.$files))
{
$file[]=$pref.$files;
}
}
}
closedir($dh);
}
return $file;
}
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;
/**
* Converts an Unix timestamp to a four byte DOS date and time format (date
* in high two bytes, time in low two bytes allowing magnitude comparison).
*
* @param integer the current Unix timestamp
*
* @return integer the current date in a four byte DOS format
*
* @access private
*/
function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
} // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method
/**
* Adds "file" to archive
*
* @param string file contents
* @param string name of the file in the archive (may contains the path)
* @param integer the current timestamp
*
* @access public
*/
function addFile($data, $name, $time = 0)
{
$name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x08\x00"; // compression method
$fr .= $hexdtime; // last mod time and date
// "local file header" segment
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$c_len = strlen($zdata);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
$fr .= pack('v', strlen($name)); // length of filename
$fr .= pack('v', 0); // extra field length
$fr .= $name;
// "file data" segment
$fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not
// served as file)
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
// add this entry to array
$this -> datasec[] = $fr;
$new_offset = strlen(implode('', $this->datasec));
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"; // version made by
$cdrec .= "\x14\x00"; // version needed to extract
$cdrec .= "\x00\x00"; // gen purpose bit flag
$cdrec .= "\x08\x00"; // compression method
$cdrec .= $hexdtime; // last mod time & date
$cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name) ); // length of filename
$cdrec .= pack('v', 0 ); // extra field length
$cdrec .= pack('v', 0 ); // file comment length
$cdrec .= pack('v', 0 ); // disk number start
$cdrec .= pack('v', 0 ); // internal file attributes
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
$this -> old_offset = $new_offset;
$cdrec .= $name;
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'addFile()' method
/**
* Dumps out file
*
* @return string the zipped file
*
* @access public
*/
function file()
{
$data = implode('', $this -> datasec);
$ctrldir = implode('', $this -> ctrl_dir);
return
$data .
$ctrldir .
$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 overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
} // 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
function extract($dir, $zipfilename){
if (function_exists("zip_open")) {
//$dir = eregi_replace("(\..*$)", "", $zipfilename);
$this->createDir($dir);
$zip = zip_open($zipfilename);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
// if (eregi("(\/)", zip_entry_name($zip_entry))) $this->createDir($dir."/".eregi_replace("\/.*$", "", zip_entry_name($zip_entry)));
// LimeSurvey Only extract first dir for the moment
if ( ! eregi("(\/)", zip_entry_name($zip_entry)))
{
$this->createFile($dir."/".zip_entry_name($zip_entry), $buf,zip_entry_filesize($zip_entry));
}
zip_entry_close($zip_entry);
}
}
zip_close($zip);
}
else
{
return "Error:OpenZip";
}
}
return 'OK';
}
function createDir($dir){
if (eregi("(\/$)", $dir)) @mkdir (substr($dir, 0, strlen($dir) - 1));
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))
{
unlink($file);
}
$fopen = fopen($file, "w");
fwrite($fopen,$data,$size);
}
} // end of the 'PHPZip' class
?>
<?php
#
# PHPZip v1.2 by Sext (sext@neud.net) 2002-11-18
# (Changed: 2003-03-01)
#
# Makes zip archive
#
# Based on "Zip file creation class", uses zLib
#
#
# Modified by Jason Cleeland - removed "subdirectory" capacity for LimeSurvey use
class PHPZip
{
function Zip($dir, $zipfilename)
{
if (@function_exists('gzcompress'))
{
$curdir = getcwd();
if (is_array($dir))
{
$filelist = $dir;
}
else
{
$filelist = $this -> GetFileList($dir);
}
if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
else chdir($curdir);
if (count($filelist)>0)
{
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);
$this -> addFile($content, $filename);
}
}
$out = $this -> file();
chdir($curdir);
$fp = fopen($zipfilename, "w");
fwrite($fp, $out, strlen($out));
fclose($fp);
}
return 1;
}
else return 0;
}
function GetFileList($dir)
{
$file=Array();
if (file_exists($dir))
{
$args = func_get_args();
if(isset($args[1])) {$pref = $args[1];} else {$pref="";}
$dh = opendir($dir);
while($files = readdir($dh))
{
if (($files!=".")&&($files!=".."))
{
if (!is_dir($dir.$files))
{
$file[]=$pref.$files;
}
}
}
closedir($dh);
}
return $file;
}
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;
/**
* Converts an Unix timestamp to a four byte DOS date and time format (date
* in high two bytes, time in low two bytes allowing magnitude comparison).
*
* @param integer the current Unix timestamp
*
* @return integer the current date in a four byte DOS format
*
* @access private
*/
function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
} // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method
/**
* Adds "file" to archive
*
* @param string file contents
* @param string name of the file in the archive (may contains the path)
* @param integer the current timestamp
*
* @access public
*/
function addFile($data, $name, $time = 0)
{
$name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x08\x00"; // compression method
$fr .= $hexdtime; // last mod time and date
// "local file header" segment
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$c_len = strlen($zdata);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
$fr .= pack('v', strlen($name)); // length of filename
$fr .= pack('v', 0); // extra field length
$fr .= $name;
// "file data" segment
$fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not
// served as file)
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
// add this entry to array
$this -> datasec[] = $fr;
$new_offset = strlen(implode('', $this->datasec));
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"; // version made by
$cdrec .= "\x14\x00"; // version needed to extract
$cdrec .= "\x00\x00"; // gen purpose bit flag
$cdrec .= "\x08\x00"; // compression method
$cdrec .= $hexdtime; // last mod time & date
$cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name) ); // length of filename
$cdrec .= pack('v', 0 ); // extra field length
$cdrec .= pack('v', 0 ); // file comment length
$cdrec .= pack('v', 0 ); // disk number start
$cdrec .= pack('v', 0 ); // internal file attributes
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
$this -> old_offset = $new_offset;
$cdrec .= $name;
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'addFile()' method
/**
* Dumps out file
*
* @return string the zipped file
*
* @access public
*/
function file()
{
$data = implode('', $this -> datasec);
$ctrldir = implode('', $this -> ctrl_dir);
return
$data .
$ctrldir .
$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 overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
} // 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
function extract($dir, $zipfilename){
if (function_exists("zip_open")) {
$this->createDir($dir);
$zip = zip_open($zipfilename);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
// LimeSurvey Only extract first dir for the moment
if ( ! preg_match("/(\/)/i", zip_entry_name($zip_entry)))
{
$this->createFile($dir."/".zip_entry_name($zip_entry), $buf,zip_entry_filesize($zip_entry));
}
zip_entry_close($zip_entry);
}
}
zip_close($zip);
}
else
{
return "Error:OpenZip";
}
}
return 'OK';
}
function createDir($dir){
if (preg_match("/(\/$)/", $dir)) @mkdir (substr($dir, 0, strlen($dir) - 1));
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))
{
unlink($file);
}
$fopen = fopen($file, "w");
fwrite($fopen,$data,$size);
}
} // end of the 'PHPZip' class
?>

View File

@@ -1,10 +0,0 @@
<?php
if (version_compare(PHP_VERSION, '5.0.0', '<') && version_compare(PHP_VERSION, '4.0.0', '>'))
{
require_once('tcpdf_php4.php');
}
else if (version_compare(PHP_VERSION, '5.0.0', '>'))
{
require_once('tcpdf.php');
}
?>

View File

@@ -1,19 +1,12 @@
<?php
require_once('checkphpversion.php');
require_once('tcpdf.php');
class PDF extends TCPDF
{
function PDF($orientation='L', $unit='mm', $format='A4')
{
if (version_compare(PHP_VERSION, '5.0.0', '<') && version_compare(PHP_VERSION, '4.0.0', '>'))
{
parent::TCPDF($orientation,$unit,$format);
}
else if(version_compare(PHP_VERSION, '5.0.0', '>'))
{
parent::__construct($orientation,$unit,$format);
}
parent::__construct($orientation,$unit,$format);
$this->SetAutoPageBreak(true,10);
$this->AliasNbPages();
@@ -21,6 +14,7 @@ class PDF extends TCPDF
function intopdf($text,$format='')
{
$text = $this->delete_html($text);
$oldformat = $this->FontStyle;
$this->SetFont('',$format,$this->FontSizePt);
$this->Write(5,$text);
@@ -31,7 +25,7 @@ class PDF extends TCPDF
{
$oldsize = $this->FontSizePt;
$this->SetFontSize($oldsize-2);
$this->Write(5,$text);
$this->Write(5,$this->delete_html($text));
$this->ln(5);
$this->SetFontSize($oldsize);
}
@@ -39,6 +33,7 @@ class PDF extends TCPDF
{
if(!empty($title))
{
$title = $this->delete_html($title);
$oldsize = $this->FontSizePt;
$this->SetFontSize($oldsize+4);
$this->Line(5,$this->y,($this->w-5),$this->y);
@@ -46,6 +41,7 @@ class PDF extends TCPDF
$this->MultiCell('','',$title,'','C',0);
if(!empty($description) && isset($description))
{
$description = $this->delete_html($description);
$this->ln(7);
$this->SetFontSize($oldsize+2);
$this->MultiCell('','',$description,'','C',0);
@@ -68,7 +64,7 @@ class PDF extends TCPDF
{
for($b=0;$b<sizeof($array[$a]);$b++)
{
$this->Cell($maxwidth[$b]*($this->FontSize),4,$array[$a][$b],0,0,'C');
$this->Cell($maxwidth[$b]*($this->FontSize),4,$this->delete_html($array[$a][$b]),0,0,'C');
}
$this->ln();
}
@@ -99,5 +95,11 @@ class PDF extends TCPDF
{
$this->Output($name,"D");
}
function delete_html($text)
{
$text = html_entity_decode($text);
return strip_tags($text);
}
}
?>

View File

@@ -5548,7 +5548,7 @@ if(!class_exists('TCPDF', false)) {
if (isset($dash)) {
$dash_string = "";
if ($dash) {
if (ereg("^.+,", $dash)) {
if (preg_match("/^.+,/", $dash)) {
$tab = explode(",", $dash);
} else {
$tab = array($dash);

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +1,92 @@
<?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: cmdline_importsurvey.php 5028 2008-06-09 11:20:29Z c_schmitz $
*/
if ($argc < 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
?>
This is a command line LimeSurvey Survey importer.
Usage:
php <?php echo $argv[0]; ?> <File to import> [<user> <password>]
<File to import> has to be a LimeSurvey survey dump.
<user> and <password> are only required if the control access is active
With the --help, -help, -h, or -? options, you can get this help.
<?php
exit;
} else {
$the_full_file_path = $argv[1];
$username = ($argc>2)? $argv[2] : "";
$userpass = ($argc>3)? $argv[3] : "";
}
if (!file_exists($the_full_file_path)) {
echo "\nThe file $the_full_file_path does not exist\n";
exit;
}
$_SERVER['SERVER_NAME'] = ""; // just to avoid notices
$_SERVER['SERVER_SOFTWARE'] = ""; // just to avoid notices
require_once(dirname(__FILE__).'/../config-defaults.php');
require_once(dirname(__FILE__).'/../common.php');
if (isset($_REQUEST['homedir'])) {die('');}
require_once($homedir."/classes/core/sha256.php");
$adminoutput =""; // just to avoid notices
include("database.php");
$query = "SELECT uid, password, lang FROM ".db_table_name('users')." WHERE users_name=".$connect->qstr($username);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $connect->SelectLimit($query, 1) or die ($query."\n".$connect->ErrorMsg());
if ($result->RecordCount() < 1)
{
// wrong or unknown username and/or email
echo "\n".$clang->gT("User name invalid!")."\n";
exit;
}
else
{
$fields = $result->FetchRow();
if (SHA256::hash($userpass) == $fields['password'])
{
$_SESSION['loginID'] = intval($fields['uid']);
$clang = new limesurvey_lang($fields['lang']);
GetSessionUserRights($_SESSION['loginID']);
if (!$_SESSION['USER_RIGHT_CREATE_SURVEY'])
{
// no permission to create survey!
echo "\n".$clang->gT("You are not allowed to import a survey!")."\n";
exit;
}
}
else
{
// password don't match username
echo "\n".$clang->gT("User name and password do not match!")."\n";
exit;
}
}
echo "\n";
$importsurvey = "";
$importingfrom = "cmdline"; // "http" for the web version and "cmdline" for the command line version
include("importsurvey.php");
?>
<?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: cmdline_importsurvey.php 6981 2009-05-30 23:04:55Z c_schmitz $
*/
if ($argc < 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
?>
This is a command line LimeSurvey Survey importer.
Usage:
php <?php echo $argv[0]; ?> <File to import> [<user> <password>]
<File to import> has to be a LimeSurvey survey dump.
<user> and <password> are only required if the control access is active
With the --help, -help, -h, or -? options, you can get this help.
<?php
exit;
} else {
$the_full_file_path = $argv[1];
$username = ($argc>2)? $argv[2] : "";
$userpass = ($argc>3)? $argv[3] : "";
}
if (!file_exists($the_full_file_path)) {
echo "\nThe file $the_full_file_path does not exist\n";
exit;
}
$_SERVER['SERVER_NAME'] = ""; // just to avoid notices
$_SERVER['SERVER_SOFTWARE'] = ""; // just to avoid notices
require_once(dirname(__FILE__).'/../config-defaults.php');
require_once(dirname(__FILE__).'/../common.php');
if (isset($_REQUEST['homedir'])) {die('');}
require_once($homedir."/classes/core/sha256.php");
$adminoutput =""; // just to avoid notices
include("database.php");
$query = "SELECT uid, password, lang FROM ".db_table_name('users')." WHERE users_name=".$connect->qstr($username);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $connect->SelectLimit($query, 1) or die ($query."\n".$connect->ErrorMsg());
if ($result->RecordCount() < 1)
{
// wrong or unknown username and/or email
echo "\n".$clang->gT("User name invalid!")."\n";
exit;
}
else
{
$fields = $result->FetchRow();
if (SHA256::hashing($userpass) == $fields['password'])
{
$_SESSION['loginID'] = intval($fields['uid']);
$clang = new limesurvey_lang($fields['lang']);
GetSessionUserRights($_SESSION['loginID']);
if (!$_SESSION['USER_RIGHT_CREATE_SURVEY'])
{
// no permission to create survey!
echo "\n".$clang->gT("You are not allowed to import a survey!")."\n";
exit;
}
}
else
{
// password don't match username
echo "\n".$clang->gT("User name and password do not match!")."\n";
exit;
}
}
echo "\n";
$importsurvey = "";
$importingfrom = "cmdline"; // "http" for the web version and "cmdline" for the command line version
include("importsurvey.php");
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,144 +1,132 @@
<?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: deactivate.php 4916 2008-05-25 17:25:33Z c_schmitz $
*/
include_once("login_check.php"); //Login Check dies also if the script is started directly
$postsid=returnglobal('sid');
$date = date('YmdHis'); //'Hi' adds 24hours+minutes to name to allow multiple deactiviations in a day
$deactivateoutput='';
if (!isset($_POST['ok']) || !$_POST['ok'])
{
$deactivateoutput .= "<br />\n<table class='alertbox'>\n";
$deactivateoutput .= "\t\t\t\t<tr ><td height='4'><strong>".$clang->gT("Deactivate Survey")." ($surveyid)</strong></td></tr>\n";
$deactivateoutput .= "\t<tr>\n";
$deactivateoutput .= "\t\t<td align='center' bgcolor='#FFEEEE'>\n";
$deactivateoutput .= "\t\t\t<font color='red'><strong>";
$deactivateoutput .= $clang->gT("Warning")."<br />".$clang->gT("READ THIS CAREFULLY BEFORE PROCEEDING");
$deactivateoutput .= "\t\t</strong></font></td>\n";
$deactivateoutput .= "\t</tr>\n";
$deactivateoutput .= "\t<tr>";
$deactivateoutput .= "\t\t<td>\n";
$deactivateoutput .= "\t\t\t".$clang->gT("In an active survey, a table is created to store all the data-entry records.")."\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("When you deactivate a survey all the data entered in the original table will be moved elsewhere, and when you activate the survey again, the table will be empty. You will not be able to access this data using LimeSurvey any more.")."</p>\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("Deactivated survey data can only be accessed by system administrators using a Database data access tool like phpmyadmin. If your survey uses tokens, this table will also be renamed and will only be accessible by system administrators.")."</p>\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("Your responses table will be renamed to:")." {$dbprefix}old_{$_GET['sid']}_{$date}</p>\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("Also you should export your responses before deactivating.")."</p>\n";
$deactivateoutput .= "\t\t</td>\n";
$deactivateoutput .= "\t</tr>\n";
$deactivateoutput .= "\t<tr>\n";
$deactivateoutput .= "\t\t<td align='center'>\n";
// $deactivateoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Deactivate Survey")."' onclick=\"window.open('$scriptname?action=deactivate&amp;ok=Y&amp;sid={$_GET['sid']}', '_self')\">\n";
$deactivateoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Deactivate Survey")."' onclick=\"".get2post("$scriptname?action=deactivate&amp;ok=Y&amp;sid={$_GET['sid']}")."\">\n";
$deactivateoutput .= "\t\t<br />&nbsp;</td>\n";
$deactivateoutput .= "\t</tr>\n";
$deactivateoutput .= "</table><br />&nbsp;\n";
}
else
{
//See if there is a tokens table for this survey
$tablelist = $connect->MetaTables();
if (in_array("{$dbprefix}tokens_{$postsid}", $tablelist))
{
$toldtable="tokens_{$postsid}";
$tnewtable="old_tokens_{$postsid}_{$date}";
$tdeactivatequery = db_rename_table(db_table_name_nq($toldtable) ,db_table_name_nq($tnewtable));
$tdeactivateresult = $connect->Execute($tdeactivatequery) or die ("Couldn't deactivate tokens table because:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
if ($databasetype=='postgres')
{
// If you deactivate a postgres table you have to rename the according sequence too and alter the id field to point to the changed sequence
$deactivatequery = db_rename_table(db_table_name_nq($toldtable).'_tid_seq',db_table_name_nq($tnewtable).'_tid_seq');
$deactivateresult = $connect->Execute($deactivatequery) or die ("Could not rename the old sequence for this token table. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
$setsequence="ALTER TABLE ".db_table_name_nq($tnewtable)." ALTER COLUMN tid SET DEFAULT nextval('".db_table_name_nq($tnewtable)."_tid_seq'::regclass);";
$deactivateresult = $connect->Execute($setsequence) or die ("Could not alter the field 'tid' to point to the new sequence name for this token table. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
$setidx="ALTER INDEX ".db_table_name_nq($toldtable)."_idx RENAME TO ".db_table_name_nq($tnewtable)."_idx;";
$deactivateresult = $connect->Execute($setidx) or die ("Could not alter the index for this token table. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$_GET['sid']}'>".$clang->gT("Main Admin Screen")."</a>");
}
}
// IF there are any records in the saved_control table related to this survey, they have to be deleted
$query = "DELETE FROM {$dbprefix}saved_control WHERE sid={$postsid}";
$result = $connect->Execute($query);
$oldtable="{$dbprefix}survey_{$postsid}";
$newtable="{$dbprefix}old_survey_{$postsid}_{$date}";
//Update the auto_increment value from the table before renaming
$new_autonumber_start=0;
$query = "SELECT id FROM $oldtable ORDER BY id desc";
$result = db_select_limit_assoc($query, 1,-1, false, false);
if ($result)
{
while ($row=$result->FetchRow())
{
if (strlen($row['id']) > 12) //Handle very large autonumbers (like those using IP prefixes)
{
$part1=substr($row['id'], 0, 12);
$part2len=strlen($row['id'])-12;
$part2=sprintf("%0{$part2len}d", substr($row['id'], 12, strlen($row['id'])-12)+1);
$new_autonumber_start="{$part1}{$part2}";
}
else
{
$new_autonumber_start=$row['id']+1;
}
}
}
$query = "UPDATE {$dbprefix}surveys SET autonumber_start=$new_autonumber_start WHERE sid=$surveyid";
@$result = $connect->Execute($query); //Note this won't die if it fails - that's deliberate.
$deactivatequery = db_rename_table($oldtable,$newtable);
$deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
if ($databasetype=='postgres')
{
// If you deactivate a postgres table you have to rename the according sequence too and alter the id field to point to the changed sequence
$deactivatequery = db_rename_table($oldtable.'_id_seq',$newtable.'_id_seq');
$deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
$setsequence="ALTER TABLE $newtable ALTER COLUMN id SET DEFAULT nextval('{$newtable}_id_seq'::regclass);";
$deactivateresult = $connect->Execute($setsequence) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
}
// $dict = NewDataDictionary($connect);
// $dropindexquery=$dict->DropIndexSQL(db_table_name_nq($oldtable).'_idx');
// $connect->Execute($dropindexquery[0]);
$deactivatequery = "UPDATE {$dbprefix}surveys SET active='N' WHERE sid=$surveyid";
$deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't deactivate because:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br /><a href='$scriptname?sid={$postsid}'>Admin</a>");
$deactivateoutput .= "<br />\n<table class='alertbox'>\n";
$deactivateoutput .= "\t\t\t\t<tr ><td height='4'><strong>".$clang->gT("Deactivate Survey")." ($surveyid)</strong></td></tr>\n";
$deactivateoutput .= "\t<tr>\n";
$deactivateoutput .= "\t\t<td align='center'>\n";
$deactivateoutput .= "\t\t\t<strong>".$clang->gT("Survey Has Been Deactivated")."\n";
$deactivateoutput .= "\t\t</strong></td>\n";
$deactivateoutput .= "\t</tr>\n";
$deactivateoutput .= "\t<tr>\n";
$deactivateoutput .= "\t\t<td>\n";
$deactivateoutput .= "\t\t\t".$clang->gT("The responses table has been renamed to: ")." $newtable.\n";
$deactivateoutput .= "\t\t\t".$clang->gT("The responses to this survey are no longer available using LimeSurvey.")."\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("You should note the name of this table in case you need to access this information later.")."</p>\n";
if (isset($toldtable) && $toldtable)
{
$deactivateoutput .= "\t\t\t".$clang->gT("The tokens table associated with this survey has been renamed to: ")." $tnewtable.\n";
}
$deactivateoutput .= "\t\t</td>\n";
$deactivateoutput .= "\t</tr>\n";
$deactivateoutput .= "</table><br/>&nbsp;\n";
}
?>
<?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: deactivate.php 6976 2009-05-30 00:53:41Z c_schmitz $
*/
include_once("login_check.php"); //Login Check dies also if the script is started directly
$postsid=returnglobal('sid');
$date = date('YmdHis'); //'Hi' adds 24hours+minutes to name to allow multiple deactiviations in a day
$deactivateoutput='';
if (!isset($_POST['ok']) || !$_POST['ok'])
{
$deactivateoutput .= "<br />\n<div class='messagebox'>\n";
$deactivateoutput .= "\t\t\t\t<div class='header'>".$clang->gT("Deactivate Survey")." ($surveyid)</div>\n";
$deactivateoutput .= "\t<div class='warningheader'>\n";
$deactivateoutput .= $clang->gT("Warning")."<br />".$clang->gT("READ THIS CAREFULLY BEFORE PROCEEDING");
$deactivateoutput .= "\t\t</div>\n";
$deactivateoutput .= "\t\t\t".$clang->gT("In an active survey, a table is created to store all the data-entry records.")."\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("When you deactivate a survey all the data entered in the original table will be moved elsewhere, and when you activate the survey again, the table will be empty. You will not be able to access this data using LimeSurvey any more.")."</p>\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("Deactivated survey data can only be accessed by system administrators using a Database data access tool like phpmyadmin. If your survey uses tokens, this table will also be renamed and will only be accessible by system administrators.")."</p>\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("Your responses table will be renamed to:")." {$dbprefix}old_{$_GET['sid']}_{$date}</p>\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("Also you should export your responses before deactivating.")."</p>\n";
$deactivateoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Deactivate Survey")."' onclick=\"".get2post("$scriptname?action=deactivate&amp;ok=Y&amp;sid={$_GET['sid']}")."\" />\n";
$deactivateoutput .= "</div><br />\n";
}
else
{
//See if there is a tokens table for this survey
$tablelist = $connect->MetaTables();
if (in_array("{$dbprefix}tokens_{$postsid}", $tablelist))
{
$toldtable="tokens_{$postsid}";
$tnewtable="old_tokens_{$postsid}_{$date}";
$tdeactivatequery = db_rename_table(db_table_name_nq($toldtable) ,db_table_name_nq($tnewtable));
$tdeactivateresult = $connect->Execute($tdeactivatequery) or die ("Couldn't deactivate tokens table because:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
if ($databasetype=='postgres')
{
// If you deactivate a postgres table you have to rename the according sequence too and alter the id field to point to the changed sequence
$deactivatequery = db_rename_table(db_table_name_nq($toldtable).'_tid_seq',db_table_name_nq($tnewtable).'_tid_seq');
$deactivateresult = $connect->Execute($deactivatequery) or die ("Could not rename the old sequence for this token table. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
$setsequence="ALTER TABLE ".db_table_name_nq($tnewtable)." ALTER COLUMN tid SET DEFAULT nextval('".db_table_name_nq($tnewtable)."_tid_seq'::regclass);";
$deactivateresult = $connect->Execute($setsequence) or die ("Could not alter the field 'tid' to point to the new sequence name for this token table. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
$setidx="ALTER INDEX ".db_table_name_nq($toldtable)."_idx RENAME TO ".db_table_name_nq($tnewtable)."_idx;";
$deactivateresult = $connect->Execute($setidx) or die ("Could not alter the index for this token table. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$_GET['sid']}'>".$clang->gT("Main Admin Screen")."</a>");
}
}
// IF there are any records in the saved_control table related to this survey, they have to be deleted
$query = "DELETE FROM {$dbprefix}saved_control WHERE sid={$postsid}";
$result = $connect->Execute($query);
$oldtable="{$dbprefix}survey_{$postsid}";
$newtable="{$dbprefix}old_survey_{$postsid}_{$date}";
//Update the auto_increment value from the table before renaming
$new_autonumber_start=0;
$query = "SELECT id FROM $oldtable ORDER BY id desc";
$result = db_select_limit_assoc($query, 1,-1, false, false);
if ($result)
{
while ($row=$result->FetchRow())
{
if (strlen($row['id']) > 12) //Handle very large autonumbers (like those using IP prefixes)
{
$part1=substr($row['id'], 0, 12);
$part2len=strlen($row['id'])-12;
$part2=sprintf("%0{$part2len}d", substr($row['id'], 12, strlen($row['id'])-12)+1);
$new_autonumber_start="{$part1}{$part2}";
}
else
{
$new_autonumber_start=$row['id']+1;
}
}
}
$query = "UPDATE {$dbprefix}surveys SET autonumber_start=$new_autonumber_start WHERE sid=$surveyid";
@$result = $connect->Execute($query); //Note this won't die if it fails - that's deliberate.
$deactivatequery = db_rename_table($oldtable,$newtable);
$deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
if ($databasetype=='postgres')
{
// If you deactivate a postgres table you have to rename the according sequence too and alter the id field to point to the changed sequence
$deactivatequery = db_rename_table($oldtable.'_id_seq',$newtable.'_id_seq');
$deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
$setsequence="ALTER TABLE $newtable ALTER COLUMN id SET DEFAULT nextval('{$newtable}_id_seq'::regclass);";
$deactivateresult = $connect->Execute($setsequence) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br />Survey was not deactivated either.<br /><br /><a href='$scriptname?sid={$postsid}'>".$clang->gT("Main Admin Screen")."</a>");
}
// $dict = NewDataDictionary($connect);
// $dropindexquery=$dict->DropIndexSQL(db_table_name_nq($oldtable).'_idx');
// $connect->Execute($dropindexquery[0]);
$deactivatequery = "UPDATE {$dbprefix}surveys SET active='N' WHERE sid=$surveyid";
$deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't deactivate because:<br />".htmlspecialchars($connect->ErrorMsg())."<br /><br /><a href='$scriptname?sid={$postsid}'>Admin</a>");
$deactivateoutput .= "<br />\n<table class='alertbox'>\n";
$deactivateoutput .= "\t\t\t\t<tr ><td height='4'><strong>".$clang->gT("Deactivate Survey")." ($surveyid)</strong></td></tr>\n";
$deactivateoutput .= "\t<tr>\n";
$deactivateoutput .= "\t\t<td align='center'>\n";
$deactivateoutput .= "\t\t\t<strong>".$clang->gT("Survey Has Been Deactivated")."\n";
$deactivateoutput .= "\t\t</strong></td>\n";
$deactivateoutput .= "\t</tr>\n";
$deactivateoutput .= "\t<tr>\n";
$deactivateoutput .= "\t\t<td>\n";
$deactivateoutput .= "\t\t\t".$clang->gT("The responses table has been renamed to: ")." $newtable.\n";
$deactivateoutput .= "\t\t\t".$clang->gT("The responses to this survey are no longer available using LimeSurvey.")."\n";
$deactivateoutput .= "\t\t\t<p>".$clang->gT("You should note the name of this table in case you need to access this information later.")."</p>\n";
if (isset($toldtable) && $toldtable)
{
$deactivateoutput .= "\t\t\t".$clang->gT("The tokens table associated with this survey has been renamed to: ")." $tnewtable.\n";
}
$deactivateoutput .= "\t\t</td>\n";
$deactivateoutput .= "\t</tr>\n";
$deactivateoutput .= "</table><br/>&nbsp;\n";
}
?>

View File

@@ -1,133 +1,141 @@
<?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: deletesurvey.php 4973 2008-06-01 14:07:01Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
$deleteok = returnglobal('deleteok');
$deletesurveyoutput = "<br />\n";
$deletesurveyoutput .= "<table class='alertbox' >\n";
$deletesurveyoutput .= "\t<tr ><td colspan='2' height='4'><font size='1'><strong>".$clang->gT("Delete Survey")."</strong></font></td></tr>\n";
if (!isset($surveyid) || !$surveyid)
{
$deletesurveyoutput .= "\t<tr ><td align='center'>\n";
$deletesurveyoutput .= "<br /><font color='red'><strong>".$clang->gT("Error")."</strong></font><br />\n";
$deletesurveyoutput .= $clang->gT("You have not selected a survey to delete")."<br /><br />\n";
$deletesurveyoutput .= "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
$deletesurveyoutput .= "</td></tr></table>\n";
$deletesurveyoutput .= "</body>\n</html>";
return;
}
if (!isset($deleteok) || !$deleteok)
{
$tablelist = $connect->MetaTables();
$deletesurveyoutput .= "\t<tr>\n";
$deletesurveyoutput .= "\t\t<td align='center'><br />\n";
$deletesurveyoutput .= "\t\t\t<font color='red'><strong>".$clang->gT("Warning")."</strong></font><br />\n";
$deletesurveyoutput .= "\t\t\t<strong>".$clang->gT("You are about to delete this survey")." ($surveyid)</strong><br /><br />\n";
$deletesurveyoutput .= "\t\t\t".$clang->gT("This process will delete this survey, and all related groups, questions answers and conditions.")."<br /><br />\n";
$deletesurveyoutput .= "\t\t\t".$clang->gT("We recommend that before you delete this survey you export the entire survey from the main administration screen.")."\n";
if (in_array("{$dbprefix}survey_$surveyid", $tablelist))
{
$deletesurveyoutput .= "\t\t\t<br /><br />\n".$clang->gT("This survey is active and a responses table exists. If you delete this survey, these responses will be deleted. We recommend that you export the responses before deleting this survey.")."<br /><br />\n";
}
if (in_array("{$dbprefix}tokens_$surveyid", $tablelist))
{
$deletesurveyoutput .= "\t\t\t".$clang->gT("This survey has an associated tokens table. If you delete this survey this tokens table will be deleted. We recommend that you export or backup these tokens before deleting this survey.")."<br /><br />\n";
}
$deletesurveyoutput .= "\t\t</td>\n";
$deletesurveyoutput .= "\t</tr>\n";
$deletesurveyoutput .= "\t<tr>\n";
$deletesurveyoutput .= "\t\t<td align='center'><br />\n";
$deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Cancel")."' onclick=\"window.open('admin.php?sid=$surveyid', '_self')\" /><br />\n";
// $deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Delete")."' onclick=\"window.open('$scriptname?action=deletesurvey&amp;sid=$surveyid&amp;ok=Y','_self')\" />\n";
$deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Delete")."' onclick=\"".get2post("$scriptname?action=deletesurvey&amp;sid=$surveyid&amp;deleteok=Y")."\" />\n";
$deletesurveyoutput .= "\t\t</td>\n";
$deletesurveyoutput .= "\t</tr>\n";
$deletesurveyoutput .= "\n";
}
else //delete the survey
{
$tablelist = $connect->MetaTables();
$dict = NewDataDictionary($connect);
if (in_array("{$dbprefix}survey_$surveyid", $tablelist)) //delete the survey_$surveyid table
{
$dsquery = $dict->DropTableSQL("{$dbprefix}survey_$surveyid");
//$dict->ExecuteSQLArray($sqlarray);
$dsresult = $dict->ExecuteSQLArray($dsquery) or safe_die ("Couldn't \"$dsquery\" because <br />".$connect->ErrorMsg());
}
if (in_array("{$dbprefix}tokens_$surveyid", $tablelist)) //delete the tokens_$surveyid table
{
$dsquery = $dict->DropTableSQL("{$dbprefix}tokens_$surveyid");
$dsresult = $dict->ExecuteSQLArray($dsquery) or safe_die ("Couldn't \"$dsquery\" because <br />".$connect->ErrorMsg());
}
$dsquery = "SELECT qid FROM {$dbprefix}questions WHERE sid=$surveyid";
$dsresult = db_execute_assoc($dsquery) or safe_die ("Couldn't find matching survey to delete<br />$dsquery<br />".$connect->ErrorMsg());
while ($dsrow = $dsresult->FetchRow())
{
$asdel = "DELETE FROM {$dbprefix}answers WHERE qid={$dsrow['qid']}";
$asres = $connect->Execute($asdel);
$cddel = "DELETE FROM {$dbprefix}conditions WHERE qid={$dsrow['qid']}";
$cdres = $connect->Execute($cddel) or safe_die ("Delete conditions failed<br />$cddel<br />".$connect->ErrorMsg());
$qadel = "DELETE FROM {$dbprefix}question_attributes WHERE qid={$dsrow['qid']}";
$qares = $connect->Execute($qadel);
}
$qdel = "DELETE FROM {$dbprefix}questions WHERE sid=$surveyid";
$qres = $connect->Execute($qdel);
$scdel = "DELETE FROM {$dbprefix}assessments WHERE sid=$surveyid";
$scres = $connect->Execute($scdel);
$gdel = "DELETE FROM {$dbprefix}groups WHERE sid=$surveyid";
$gres = $connect->Execute($gdel);
$slsdel = "DELETE FROM {$dbprefix}surveys_languagesettings WHERE surveyls_survey_id=$surveyid";
$slsres = $connect->Execute($slsdel);
$srdel = "DELETE FROM {$dbprefix}surveys_rights WHERE sid=$surveyid";
$srres = $connect->Execute($srdel);
$srdel = "DELETE FROM {$dbprefix}saved_control WHERE sid=$surveyid";
$srres = $connect->Execute($srdel);
$sdel = "DELETE FROM {$dbprefix}surveys WHERE sid=$surveyid";
$sres = $connect->Execute($sdel);
$deletesurveyoutput .= "\t<tr>\n";
$deletesurveyoutput .= "\t\t<td align='center'><br />\n";
$deletesurveyoutput .= "\t\t\t<strong>".$clang->gT("This survey has been deleted.")."<br /><br />\n";
$deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\" />\n";
$deletesurveyoutput .= "\t\t</strong></td>\n";
$deletesurveyoutput .= "\t</tr>\n";
$surveyid=false;
}
$deletesurveyoutput .= "</table><br />&nbsp;\n";
?>
<?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: deletesurvey.php 7503 2009-08-21 00:30:44Z jcleeland $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
$deleteok = returnglobal('deleteok');
$deletesurveyoutput = "<br />\n";
$deletesurveyoutput .= "<table class='alertbox' >\n";
$deletesurveyoutput .= "\t<tr ><td colspan='2' height='4'><font size='1'><strong>".$clang->gT("Delete Survey")."</strong></font></td></tr>\n";
if (!isset($surveyid) || !$surveyid)
{
$deletesurveyoutput .= "\t<tr ><td align='center'>\n";
$deletesurveyoutput .= "<br /><font color='red'><strong>".$clang->gT("Error")."</strong></font><br />\n";
$deletesurveyoutput .= $clang->gT("You have not selected a survey to delete")."<br /><br />\n";
$deletesurveyoutput .= "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
$deletesurveyoutput .= "</td></tr></table>\n";
$deletesurveyoutput .= "</body>\n</html>";
return;
}
if (!isset($deleteok) || !$deleteok)
{
$tablelist = $connect->MetaTables();
$deletesurveyoutput .= "\t<tr>\n";
$deletesurveyoutput .= "\t\t<td align='center'><br />\n";
$deletesurveyoutput .= "\t\t\t<font color='red'><strong>".$clang->gT("Warning")."</strong></font><br />\n";
$deletesurveyoutput .= "\t\t\t<strong>".$clang->gT("You are about to delete this survey")." ($surveyid)</strong><br /><br />\n";
$deletesurveyoutput .= "\t\t\t".$clang->gT("This process will delete this survey, and all related groups, questions answers and conditions.")."<br /><br />\n";
$deletesurveyoutput .= "\t\t\t".$clang->gT("We recommend that before you delete this survey you export the entire survey from the main administration screen.")."\n";
if (in_array("{$dbprefix}survey_$surveyid", $tablelist))
{
$deletesurveyoutput .= "\t\t\t<br /><br />\n".$clang->gT("This survey is active and a responses table exists. If you delete this survey, these responses will be deleted. We recommend that you export the responses before deleting this survey.")."<br /><br />\n";
}
if (in_array("{$dbprefix}tokens_$surveyid", $tablelist))
{
$deletesurveyoutput .= "\t\t\t".$clang->gT("This survey has an associated tokens table. If you delete this survey this tokens table will be deleted. We recommend that you export or backup these tokens before deleting this survey.")."<br /><br />\n";
}
$deletesurveyoutput .= "\t\t</td>\n";
$deletesurveyoutput .= "\t</tr>\n";
$deletesurveyoutput .= "\t<tr>\n";
$deletesurveyoutput .= "\t\t<td align='center'><br />\n";
$deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Cancel")."' onclick=\"window.open('admin.php?sid=$surveyid', '_self')\" /><br />\n";
// $deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Delete")."' onclick=\"window.open('$scriptname?action=deletesurvey&amp;sid=$surveyid&amp;ok=Y','_top')\" />\n";
$deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Delete")."' onclick=\"".get2post("$scriptname?action=deletesurvey&amp;sid=$surveyid&amp;deleteok=Y")."\" />\n";
$deletesurveyoutput .= "\t\t</td>\n";
$deletesurveyoutput .= "\t</tr>\n";
$deletesurveyoutput .= "\n";
}
else //delete the survey
{
$tablelist = $connect->MetaTables();
$dict = NewDataDictionary($connect);
if (in_array("{$dbprefix}survey_$surveyid", $tablelist)) //delete the survey_$surveyid table
{
$dsquery = $dict->DropTableSQL("{$dbprefix}survey_$surveyid");
//$dict->ExecuteSQLArray($sqlarray);
$dsresult = $dict->ExecuteSQLArray($dsquery) or safe_die ("Couldn't \"$dsquery\" because <br />".$connect->ErrorMsg());
}
if (in_array("{$dbprefix}tokens_$surveyid", $tablelist)) //delete the tokens_$surveyid table
{
$dsquery = $dict->DropTableSQL("{$dbprefix}tokens_$surveyid");
$dsresult = $dict->ExecuteSQLArray($dsquery) or safe_die ("Couldn't \"$dsquery\" because <br />".$connect->ErrorMsg());
}
$dsquery = "SELECT qid FROM {$dbprefix}questions WHERE sid=$surveyid";
$dsresult = db_execute_assoc($dsquery) or safe_die ("Couldn't find matching survey to delete<br />$dsquery<br />".$connect->ErrorMsg());
while ($dsrow = $dsresult->FetchRow())
{
$asdel = "DELETE FROM {$dbprefix}answers WHERE qid={$dsrow['qid']}";
$asres = $connect->Execute($asdel);
$cddel = "DELETE FROM {$dbprefix}conditions WHERE qid={$dsrow['qid']}";
$cdres = $connect->Execute($cddel) or safe_die ("Delete conditions failed<br />$cddel<br />".$connect->ErrorMsg());
$qadel = "DELETE FROM {$dbprefix}question_attributes WHERE qid={$dsrow['qid']}";
$qares = $connect->Execute($qadel);
}
$qdel = "DELETE FROM {$dbprefix}questions WHERE sid=$surveyid";
$qres = $connect->Execute($qdel);
$scdel = "DELETE FROM {$dbprefix}assessments WHERE sid=$surveyid";
$scres = $connect->Execute($scdel);
$gdel = "DELETE FROM {$dbprefix}groups WHERE sid=$surveyid";
$gres = $connect->Execute($gdel);
$slsdel = "DELETE FROM {$dbprefix}surveys_languagesettings WHERE surveyls_survey_id=$surveyid";
$slsres = $connect->Execute($slsdel);
$srdel = "DELETE FROM {$dbprefix}surveys_rights WHERE sid=$surveyid";
$srres = $connect->Execute($srdel);
$srdel = "DELETE FROM {$dbprefix}saved_control WHERE sid=$surveyid";
$srres = $connect->Execute($srdel);
$sdel = "DELETE FROM {$dbprefix}surveys WHERE sid=$surveyid";
$sres = $connect->Execute($sdel);
$sdel = "DELETE {$dbprefix}quota_languagesettings FROM {$dbprefix}quota_languagesettings, {$dbprefix}quota WHERE {$dbprefix}quota_languagesettings.quotals_quota_id={$dbprefix}quota.id and sid=$surveyid";
$sres = $connect->Execute($sdel);
$sdel = "DELETE FROM {$dbprefix}quota WHERE sid=$surveyid";
$sres = $connect->Execute($sdel);
$sdel = "DELETE FROM {$dbprefix}quota_members WHERE sid=$surveyid;";
$sres = $connect->Execute($sdel);
$deletesurveyoutput .= "\t<tr>\n";
$deletesurveyoutput .= "\t\t<td align='center'><br />\n";
$deletesurveyoutput .= "\t\t\t<strong>".$clang->gT("This survey has been deleted.")."<br /><br />\n";
$deletesurveyoutput .= "\t\t\t<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\" />\n";
$deletesurveyoutput .= "\t\t</strong></td>\n";
$deletesurveyoutput .= "\t</tr>\n";
$surveyid=false;
}
$deletesurveyoutput .= "</table><br />&nbsp;\n";
?>

View File

@@ -1,129 +1,137 @@
<?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: dumpdb.php 4727 2008-04-29 04:31:51Z jcleeland $
*/
include_once("login_check.php"); //Login Check dies also if the script is started directly
if ($database_exists && $databasetype=='mysql') {
$tables = $connect->MetaTables();
$export="";
$export .="#------------------------------------------"."\n";
$export .="# LimeSurvey Database Dump of `$databasename`"."\n";
if ($allowexportalldb==0) {
$export .="# Only prefixed tables with: ". $dbprefix ."\n";
}
$export .="# Date of Dump: ". date("d-M-Y") ."\n";
$export .="#------------------------------------------"."\n\n\n";
foreach($tables as $table) {
if ($allowexportalldb==0) {
if ($dbprefix==substr($table, 0, strlen($dbprefix))) {
$export .= defdump($table);
$export .= datadump($table);
}
}
else {
$export .= defdump($table);
$export .= datadump($table);
}
}
$file_name = "LimeSurvey_{$databasename}_dump_".date_shift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust).".sql";
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=$file_name");
Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
echo $export;
exit;
}
else
{
$dumpdboutput= "<br />\n"
."<table class='alertbox' >\n"
."\t<tr ><td height='4'><font size='1'><strong>".$clang->gT("Export database")."</strong></font></td></tr>\n"
."\t<tr ><td height='4'>".$clang->gT("The database export is only available for MySQL databases. For other database types please use the according backup mechanism to create a database dump.")."</td></tr>"
."</table><br />";
return;
}
function defdump($tablename)
{
global $connect;
$def = "";
$def .="#------------------------------------------"."\n";
$def .="# Table definition for $tablename"."\n";
$def .="#------------------------------------------"."\n";
$def .= "DROP TABLE IF EXISTS $tablename;"."\n"."\n";
$def .= "CREATE TABLE $tablename ("."\n";
$result = db_execute_assoc("SHOW COLUMNS FROM $tablename") or die("Table $tablename not existing in database");
while($row = $result->FetchRow())
{
$def .= " `$row[Field]` $row[Type]";
if (!is_null($row["Default"])) $def .= " DEFAULT '$row[Default]'";
if ($row["Null"] != "YES") $def .= " NOT NULL";
if ($row["Extra"] != "") $def .= " $row[Extra]";
$def .= ",\n";
}
$def = ereg_replace(",\n$","", $def);
$result = db_execute_assoc("SHOW KEYS FROM $tablename");
while($row = $result->FetchRow())
{
$kname=$row["Key_name"];
if(($kname != "PRIMARY") && ($row["Non_unique"] == 0)) $kname="UNIQUE|$kname";
if(!isset($index[$kname])) $index[$kname] = array();
$index[$kname][] = $row["Column_name"];
}
while(list($x, $columns) = @each($index))
{
$def .= ",\n";
if($x == "PRIMARY") $def .= " PRIMARY KEY (" . implode($columns, ", ") . ")";
else if (substr($x,0,6) == "UNIQUE") $def .= " UNIQUE ".substr($x,7)." (" . implode($columns, ", ") . ")";
else $def .= " KEY $x (" . implode($columns, ", ") . ")";
}
$def .= "\n);\n\n\n";
return (stripslashes($def));
}
function datadump ($table) {
global $connect;
$result = "#------------------------------------------"."\n";
$result .="# Table data for $table"."\n";
$result .="#------------------------------------------"."\n";
$query = db_execute_num("select * from $table");
$num_fields = $query->FieldCount();
$numrow = $query->RecordCount();
while($row=$query->FetchRow()){
@set_time_limit(5);
$result .= "INSERT INTO ".$table." VALUES(";
for($j=0; $j<$num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) $result .= "\"$row[$j]\"" ; else $result .= "\"\"";
if ($j<($num_fields-1)) $result .= ",";
}
$result .= ");\n";
} // while
return $result . "\n\n\n";
}
?>
<?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: dumpdb.php 7519 2009-08-23 21:55:32Z c_schmitz $
*/
include_once("login_check.php"); //Login Check dies also if the script is started directly
if ($database_exists && ($databasetype=='mysql' || $databasetype=='mysqli') && $demoModeOnly != true) {
$tables = $connect->MetaTables();
$export="";
$export .="#------------------------------------------"."\n";
$export .="# LimeSurvey Database Dump of `$databasename`"."\n";
if ($allowexportalldb==0) {
$export .="# Only prefixed tables with: ". $dbprefix ."\n";
}
$export .="# Date of Dump: ". date("d-M-Y") ."\n";
$export .="#------------------------------------------"."\n\n\n";
foreach($tables as $table) {
if ($allowexportalldb==0) {
if ($dbprefix==substr($table, 0, strlen($dbprefix))) {
$export .= defdump($table);
$export .= datadump($table);
}
}
else {
$export .= defdump($table);
$export .= datadump($table);
}
}
$file_name = "LimeSurvey_{$databasename}_dump_".date_shift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust).".sql";
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=$file_name");
Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
echo $export;
exit;
}
else
{
$dumpdboutput= "<br />\n"
."<table class='alertbox' >\n"
."\t<tr ><td height='4'><font size='1'><strong>".$clang->gT("Export database")."</strong></font></td></tr>\n"
."\t<tr ><td height='4'>".$clang->gT("The database export is only available for MySQL databases. For other database types please use the according backup mechanism to create a database dump.")."</td></tr>"
."</table><br />";
return;
}
function defdump($tablename)
{
global $connect;
$def = "";
$def .="#------------------------------------------"."\n";
$def .="# Table definition for $tablename"."\n";
$def .="#------------------------------------------"."\n";
$def .= "DROP TABLE IF EXISTS $tablename;"."\n"."\n";
$def .= "CREATE TABLE $tablename ("."\n";
$result = db_execute_assoc("SHOW COLUMNS FROM $tablename") or die("Table $tablename not existing in database");
while($row = $result->FetchRow())
{
$def .= " `$row[Field]` $row[Type]";
if (!is_null($row["Default"])) $def .= " DEFAULT '$row[Default]'";
if ($row["Null"] != "YES") $def .= " NOT NULL";
if ($row["Extra"] != "") $def .= " $row[Extra]";
$def .= ",\n";
}
$def = preg_replace("#,\n$#","", $def);
$result = db_execute_assoc("SHOW KEYS FROM $tablename");
while($row = $result->FetchRow())
{
$kname=$row["Key_name"];
if(($kname != "PRIMARY") && ($row["Non_unique"] == 0)) $kname="UNIQUE|$kname";
if(!isset($index[$kname])) $index[$kname] = array();
$index[$kname][] = $row["Column_name"];
}
while(list($x, $columns) = @each($index))
{
$def .= ",\n";
if($x == "PRIMARY") $def .= " PRIMARY KEY (" . implode($columns, ", ") . ")";
else if (substr($x,0,6) == "UNIQUE") $def .= " UNIQUE ".substr($x,7)." (" . implode($columns, ", ") . ")";
else $def .= " KEY $x (" . implode($columns, ", ") . ")";
}
$def .= "\n);\n\n\n";
return (stripslashes($def));
}
function datadump ($table) {
global $connect;
$result = "#------------------------------------------"."\n";
$result .="# Table data for $table"."\n";
$result .="#------------------------------------------"."\n";
$query = db_execute_num("select * from $table");
$num_fields = $query->FieldCount();
$numrow = $query->RecordCount();
while($row=$query->FetchRow()){
@set_time_limit(5);
$result .= "INSERT INTO ".$table." VALUES(";
for($j=0; $j<$num_fields; $j++) {
if (isset($row[$j]) && !is_null($row[$j]))
{
$row[$j] = addslashes($row[$j]);
$row[$j] = preg_replace("#\n#","\\n",$row[$j]);
$result .= "\"$row[$j]\"";
}
else
{
$result .= "NULL";
}
if ($j<($num_fields-1)) $result .= ",";
}
$result .= ");\n";
} // while
return $result . "\n\n\n";
}
?>

View File

@@ -1,95 +1,155 @@
<?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: dumpgroup.php 4646 2008-04-14 18:47:45Z awarren $
*/
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
// 1. questions
// 2. answers
include_once("login_check.php");
$gid = returnglobal('gid');
$surveyid = returnglobal('sid');
//Ensure script is not run directly, avoid path disclosure
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
//echo $htmlheader;
if (!$gid)
{
echo $htmlheader;
echo "<br />\n";
echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Export Question")."</strong></td></tr>\n";
echo "\t<tr bgcolor='#CCCCCC'><td align='center'>$setfont\n";
echo "$setfont<br /><strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n"._EQ_NOGID."<br />\n";
echo "<br /><input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
echo "\t</td></tr>\n";
echo "</table>\n";
echo "</body></html>\n";
exit;
}
$fn = "limesurvey_group_$gid.csv";
$dumphead = "# LimeSurvey Group Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped group from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");
//0: Groups Table
$gquery = "SELECT * FROM {$dbprefix}groups WHERE gid=$gid";
$gdump = BuildCSVFromQuery($gquery);
//1: Questions Table
$qquery = "SELECT * FROM {$dbprefix}questions WHERE gid=$gid";
$qdump = BuildCSVFromQuery($qquery);
//2: Answers table
$aquery = "SELECT DISTINCT {$dbprefix}answers.* FROM {$dbprefix}answers, {$dbprefix}questions WHERE ({$dbprefix}answers.qid={$dbprefix}questions.qid) AND ({$dbprefix}questions.gid=$gid)";
$adump = BuildCSVFromQuery($aquery);
//3: Conditions table - THIS CAN ONLY EXPORT CONDITIONS THAT RELATE TO THE SAME GROUP
$cquery = "SELECT DISTINCT {$dbprefix}conditions.* FROM {$dbprefix}conditions, {$dbprefix}questions, {$dbprefix}questions b WHERE ({$dbprefix}conditions.cqid={$dbprefix}questions.qid) AND ({$dbprefix}conditions.qid=b.qid) AND ({$dbprefix}questions.gid=$gid) AND (b.gid=$gid)";
$cdump = BuildCSVFromQuery($cquery);
//4: Labelsets Table
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.* FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE ({$dbprefix}labelsets.lid={$dbprefix}questions.lid) AND (type in ('F', 'H', 'Z', 'W')) AND (gid=$gid)";
$lsdump = BuildCSVFromQuery($lsquery);
//5: Labels Table
$lquery = "SELECT {$dbprefix}labels.* FROM {$dbprefix}labels, {$dbprefix}questions WHERE ({$dbprefix}labels.lid={$dbprefix}questions.lid) AND (type in ('F', 'H', 'Z', 'W')) AND (gid=$gid)";
$ldump = BuildCSVFromQuery($lquery);
//8: Question Attributes
$query = "SELECT DISTINCT {$dbprefix}question_attributes.* FROM {$dbprefix}question_attributes, {$dbprefix}questions WHERE ({$dbprefix}question_attributes.qid={$dbprefix}questions.qid) AND ({$dbprefix}questions.gid=$gid)";
$qadump = BuildCSVFromQuery($query);
// HTTP/1.0
echo $dumphead, $gdump, $qdump, $adump, $cdump, $lsdump, $ldump, $qadump;
exit;
?>
<?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: dumpgroup.php 6853 2009-05-15 12:51:09Z c_schmitz $
*/
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
// 1. questions
// 2. answers
include_once("login_check.php");
$gid = returnglobal('gid');
$surveyid = returnglobal('sid');
//Ensure script is not run directly, avoid path disclosure
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
//echo $htmlheader;
if (!$gid)
{
echo $htmlheader;
echo "<br />\n";
echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Export Question")."</strong></td></tr>\n";
echo "\t<tr bgcolor='#CCCCCC'><td align='center'>$setfont\n";
echo "$setfont<br /><strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n"._EQ_NOGID."<br />\n";
echo "<br /><input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
echo "\t</td></tr>\n";
echo "</table>\n";
echo "</body></html>\n";
exit;
}
$fn = "limesurvey_group_$gid.csv";
$dumphead = "# LimeSurvey Group Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped group from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");
//0: Groups Table
$gquery = "SELECT *
FROM {$dbprefix}groups
WHERE gid=$gid";
$gdump = BuildCSVFromQuery($gquery);
//1: Questions Table
$qquery = "SELECT *
FROM {$dbprefix}questions
WHERE gid=$gid";
$qdump = BuildCSVFromQuery($qquery);
//2: Answers table
$aquery = "SELECT DISTINCT {$dbprefix}answers.*
FROM {$dbprefix}answers, {$dbprefix}questions
WHERE ({$dbprefix}answers.qid={$dbprefix}questions.qid)
AND ({$dbprefix}questions.gid=$gid)";
$adump = BuildCSVFromQuery($aquery);
//3: Conditions table - THIS CAN ONLY EXPORT CONDITIONS THAT RELATE TO THE SAME GROUP
$cquery = "SELECT DISTINCT {$dbprefix}conditions.*
FROM {$dbprefix}conditions, {$dbprefix}questions, {$dbprefix}questions b
WHERE ({$dbprefix}conditions.cqid={$dbprefix}questions.qid)
AND ({$dbprefix}conditions.qid=b.qid)
AND ({$dbprefix}questions.gid=$gid)
AND (b.gid=$gid)";
$cdump = BuildCSVFromQuery($cquery);
//4: Labelsets Table
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.*
FROM {$dbprefix}labelsets, {$dbprefix}questions
WHERE ({$dbprefix}labelsets.lid={$dbprefix}questions.lid)
AND (type in ('F', 'W', 'H', 'Z', '1', ':', ';'))
AND (gid=$gid)";
$lsdump = BuildCSVFromQuery($lsquery);
//5: Labelsets1 Table
//This exists specifically to deal with dual-scale questions (or any future question that may have 2 labelsets)
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.* FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE ({$dbprefix}labelsets.lid={$dbprefix}questions.lid1) AND (type in ('1')) AND (gid=$gid)";
$ls1dump = BuildCSVFromQuery($lsquery);
$ls1=explode("\n", trim($ls1dump));
if(count($ls1)>3) {
//If there is actually some data here, then add just the data (not the headers) into
// $ls1dump - which will be outputted directly after $lsdump
$ls1dump=$ls1[4];
$ls1dump .= "\n";
} else {
//If there is no data then make it an empty string.
$ls1dump = "";
}
//4a: Labels Table
$lquery = "SELECT {$dbprefix}labels.* FROM {$dbprefix}labels, {$dbprefix}questions WHERE ({$dbprefix}labels.lid={$dbprefix}questions.lid) AND (type in ('F', 'H', 'Z', 'W', '1', ':', ';')) AND (gid=$gid)";
$ldump = BuildCSVFromQuery($lquery);
//5a: Labels1 Table
// See explanation for Labelsets1 Table!! These are the actual labels
$lquery = "SELECT {$dbprefix}labels.* FROM {$dbprefix}labels, {$dbprefix}questions WHERE ({$dbprefix}labels.lid={$dbprefix}questions.lid1) AND (type in ('1')) AND (gid=$gid)";
$l1dump = BuildCSVFromQuery($lquery);
$ld1=explode("\n", trim($l1dump));
if(count($ld1)>3) {
//If there is actually some data here, then add just the data (not the headers) into
// $l1dump - which will be outputted directly after $ldump
$l1dump=array();
foreach($ld1 as $key=>$ld) {
//Put every line, other than the first three into this string
if($key > 3) {
$l1dump[]=$ld;
}
}
$l1dump = implode("\n", $l1dump);
$l1dump .= "\n";
} else {
//If there is no data then make it an empty string.
$l1dump = "";
}
//8: Question Attributes
$query = "SELECT DISTINCT {$dbprefix}question_attributes.*
FROM {$dbprefix}question_attributes, {$dbprefix}questions
WHERE ({$dbprefix}question_attributes.qid={$dbprefix}questions.qid)
AND ({$dbprefix}questions.gid=$gid)";
$qadump = BuildCSVFromQuery($query);
// HTTP/1.0
echo $dumphead, $gdump, $qdump, $adump, $cdump, $lsdump, $ls1dump, $ldump, $l1dump, $qadump;
exit;
?>

View File

@@ -1,67 +1,67 @@
<?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: dumplabel.php 4769 2008-05-06 23:20:29Z c_schmitz $
*/
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
// 1. questions
// 2. answers
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
$lid=returnglobal('lid');
if (!$lid)
{
echo "<br />\n";
echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Export Label Set")."</strong></td></tr>\n";
echo "\t<tr bgcolor='#CCCCCC'><td align='center'>\n";
echo "<br /><strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n".$clang->gT("No LID has been provided. Cannot dump label set.")."<br />\n";
echo "<br /><input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
echo "\t</td></tr>\n";
echo "</table>\n";
echo "</body></html>\n";
exit;
}
$dumphead = "# LimeSurvey Label Set Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped label set from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
//1: Questions Table
$qquery = "SELECT * FROM {$dbprefix}labelsets WHERE lid=$lid";
$qdump = BuildCSVFromQuery($qquery);
//2: Answers table
$aquery = "SELECT lid, code, title, sortorder, language FROM {$dbprefix}labels WHERE lid=$lid";
$adump = BuildCSVFromQuery($aquery);
$fn = "limesurvey_labelset_$lid.csv";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache"); // HTTP/1.0
echo $dumphead, $qdump, $adump;
exit;
?>
<?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: dumplabel.php 7382 2009-08-01 19:48:15Z c_schmitz $
*/
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
// 1. questions
// 2. answers
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
$lid=returnglobal('lid');
if (!$lid)
{
echo "<br />\n";
echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Export Label Set")."</strong></td></tr>\n";
echo "\t<tr bgcolor='#CCCCCC'><td align='center'>\n";
echo "<br /><strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n".$clang->gT("No LID has been provided. Cannot dump label set.")."<br />\n";
echo "<br /><input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
echo "\t</td></tr>\n";
echo "</table>\n";
echo "</body></html>\n";
exit;
}
$dumphead = "# LimeSurvey Label Set Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped label set from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
//1: Questions Table
$qquery = "SELECT * FROM {$dbprefix}labelsets WHERE lid=$lid";
$qdump = BuildCSVFromQuery($qquery);
//2: Answers table
$aquery = "SELECT lid, code, title, sortorder, language, assessment_value FROM {$dbprefix}labels WHERE lid=$lid";
$adump = BuildCSVFromQuery($aquery);
$fn = "limesurvey_labelset_$lid.csv";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache"); // HTTP/1.0
echo $dumphead, $qdump, $adump;
exit;
?>

View File

@@ -1,118 +1,172 @@
<?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: dumpquestion.php 4973 2008-06-01 14:07:01Z c_schmitz $
*/
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
// 1. questions
// 2. answers
include_once("login_check.php");
$qid = returnglobal('qid');
include_once("login_check.php");
//echo $htmlheader;
if (!$qid)
{
echo $htmlheader;
echo "<br />\n";
echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Export Question")."</strong></td></tr>\n";
echo "\t<tr bgcolor='#CCCCCC'><td align='center'>\n";
echo "<br /><strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n".$clang->gT("No QID has been provided. Cannot dump question.")."<br />\n";
echo "<br /><input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
echo "\t</td></tr>\n";
echo "</table>\n";
echo "</body></html>\n";
exit;
}
$dumphead = "# LimeSurvey Question Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped question from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
function BuildOutput($Query)
{
global $dbprefix, $connect;
$QueryResult = db_execute_assoc($Query) or safe_die ("ERROR: $QueryResult<br />".$connect->ErrorMsg());
preg_match('/FROM (\w+)( |,)/i', $Query, $MatchResults);
$TableName = $MatchResults[1];;
if ($dbprefix)
{
$TableName = substr($TableName, strlen($dbprefix), strlen($TableName));
}
$Output = "\n#\n# " . strtoupper($TableName) . " TABLE\n#\n";
$HeaderDone = false; $ColumnNames = "";
while ($Row = $QueryResult->FetchRow())
{
if (!$HeaderDone)
{
foreach ($Row as $Key=>$Value)
{
$ColumnNames .= CSVEscape($Key).","; //Add all the column names together
}
$ColumnNames = substr($ColumnNames, 0, -1); //strip off last comma space
$Output .= "$ColumnNames\n";
$HeaderDone=true;
}
$ColumnValues = "";
foreach ($Row as $Key=>$Value)
{
$ColumnValues .= CSVEscape(str_replace("\r\n", "\n", $Value)) . ",";
}
$ColumnValues = substr($ColumnValues, 0, -1); //strip off last comma space
$Output .= "$ColumnValues\n";
}
return $Output;
}
//1: Questions Table
$qquery = "SELECT * FROM {$dbprefix}questions WHERE qid=$qid";
$qdump = BuildCSVFromQuery($qquery);
//2: Answers table
$aquery = "SELECT {$dbprefix}answers.* FROM {$dbprefix}answers WHERE {$dbprefix}answers.qid = $qid";
$adump = BuildCSVFromQuery($aquery);
//3: Labelsets Table
//$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.* FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid AND type='F' AND qid=$qid";
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.* FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid AND type in ('F', 'H', 'Z', 'W') AND qid=$qid";
$lsdump = BuildCSVFromQuery($lsquery);
//4: Labels Table
$lquery = "SELECT DISTINCT {$dbprefix}labels.* FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type in ('F', 'H', 'Z', 'W') AND qid=$qid";
$ldump = BuildCSVFromQuery($lquery);
//5: Question Attributes
$query = "SELECT {$dbprefix}question_attributes.* FROM {$dbprefix}question_attributes WHERE {$dbprefix}question_attributes.qid=$qid";
$qadump = BuildCSVFromQuery($query);
$fn = "limesurvey_question_$qid.csv";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache"); // HTTP/1.0
echo $dumphead, $qdump, $adump, $lsdump, $ldump, $qadump;
exit;
?>
<?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: dumpquestion.php 6853 2009-05-15 12:51:09Z c_schmitz $
*/
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
// ON ANOTHER SURVEY SETUP DUMP ALL DATA WITH RELATED QID FROM THE FOLLOWING TABLES
// 1. questions
// 2. answers
include_once("login_check.php");
$qid = returnglobal('qid');
include_once("login_check.php");
//echo $htmlheader;
if (!$qid)
{
echo $htmlheader;
echo "<br />\n";
echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Export Question")."</strong></td></tr>\n";
echo "\t<tr bgcolor='#CCCCCC'><td align='center'>\n";
echo "<br /><strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n".$clang->gT("No QID has been provided. Cannot dump question.")."<br />\n";
echo "<br /><input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
echo "\t</td></tr>\n";
echo "</table>\n";
echo "</body></html>\n";
exit;
}
$dumphead = "# LimeSurvey Question Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped question from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
function BuildOutput($Query)
{
global $dbprefix, $connect;
$QueryResult = db_execute_assoc($Query) or safe_die ("ERROR: $QueryResult<br />".$connect->ErrorMsg());
preg_match('/FROM (\w+)( |,)/i', $Query, $MatchResults);
$TableName = $MatchResults[1];;
if ($dbprefix)
{
$TableName = substr($TableName, strlen($dbprefix), strlen($TableName));
}
$Output = "\n#\n# " . strtoupper($TableName) . " TABLE\n#\n";
$HeaderDone = false; $ColumnNames = "";
while ($Row = $QueryResult->FetchRow())
{
if (!$HeaderDone)
{
foreach ($Row as $Key=>$Value)
{
$ColumnNames .= CSVEscape($Key).","; //Add all the column names together
}
$ColumnNames = substr($ColumnNames, 0, -1); //strip off last comma space
$Output .= "$ColumnNames\n";
$HeaderDone=true;
}
$ColumnValues = "";
foreach ($Row as $Key=>$Value)
{
$ColumnValues .= CSVEscape(str_replace("\r\n", "\n", $Value)) . ",";
}
$ColumnValues = substr($ColumnValues, 0, -1); //strip off last comma space
$Output .= "$ColumnValues\n";
}
return $Output;
}
//1: Questions Table
$qquery = "SELECT *
FROM {$dbprefix}questions
WHERE qid=$qid";
$qdump = BuildCSVFromQuery($qquery);
//2: Answers table
$aquery = "SELECT {$dbprefix}answers.*
FROM {$dbprefix}answers
WHERE {$dbprefix}answers.qid = $qid";
$adump = BuildCSVFromQuery($aquery);
//3: Labelsets Table
//$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.* FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid AND type='F' AND qid=$qid";
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.*
FROM {$dbprefix}labelsets, {$dbprefix}questions
WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid
AND type in ('F', 'W', 'H', 'Z', '1', ':', ';')
AND qid=$qid";
$lsdump = BuildCSVFromQuery($lsquery);
//4: Labels Table
$lquery = "SELECT DISTINCT {$dbprefix}labels.*
FROM {$dbprefix}labels, {$dbprefix}questions
WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid
AND type in ('F', 'W', 'H', 'Z', '1', ':', ';')
AND qid=$qid";
$ldump = BuildCSVFromQuery($lquery);
//4: Labelsets1 Table
//This exists specifically to deal with dual-scale questions (or any future question that may have 2 labelsets)
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.* FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid1 AND type in ('1') AND qid=$qid";
$ls1dump = BuildCSVFromQuery($lsquery);
$ls1=explode("\n", trim($ls1dump));
if(count($ls1)>3) {
//If there is actually some data here, then add just the data (not the headers) into
// $ls1dump - which will be outputted directly after $lsdump
$ls1dump=$ls1[4];
$ls1dump .= "\n";
} else {
//If there is no data then make it an empty string.
$ls1dump = "";
}
//4a: Labels1 Table
// See explanation for Labelsets1 Table!! These are the actual labels
$lquery = "SELECT DISTINCT {$dbprefix}labels.* FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid1 AND type in ('1') AND qid=$qid";
$l1dump = BuildCSVFromQuery($lquery);
$ld1=explode("\n", trim($l1dump));
if(count($ld1)>3) {
//If there is actually some data here, then add just the data (not the headers) into
// $l1dump - which will be outputted directly after $ldump
$l1dump=array();
foreach($ld1 as $key=>$ld) {
//Put every line, other than the first three into this string
if($key > 3) {
$l1dump[]=$ld;
}
}
$l1dump = implode("\n", $l1dump);
$l1dump .= "\n";
} else {
//If there is no data then make it an empty string.
$l1dump = "";
}
//5: Question Attributes
$query = "SELECT {$dbprefix}question_attributes.*
FROM {$dbprefix}question_attributes
WHERE {$dbprefix}question_attributes.qid=$qid";
$qadump = BuildCSVFromQuery($query);
$fn = "limesurvey_question_$qid.csv";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache"); // HTTP/1.0
echo $dumphead, $qdump, $adump, $lsdump, $ls1dump, $ldump, $l1dump, $qadump;
exit;
?>

View File

@@ -0,0 +1,457 @@
<?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: export_data_functions.php 7406 2009-08-05 12:25:57Z mennodekker $
*/
$length_vallabel = '120'; // Set the max text length of Value Labels
$length_data = '255'; // Set the max text length of Text Data
/**
* Strips html tags and replaces new lines
*
* @param $string
* @return $string
*/
function strip_tags_full($string) {
$string=html_entity_decode($string, ENT_QUOTES, "UTF-8");
//combining these into one mb_ereg_replace call ought to speed things up
$string = str_replace(array("\r\n","\r","\n",'-oth-'), '', $string);
//The backslashes must be escaped twice, once for php, and again for the regexp
$string = str_replace("'|\\\\'", "&apos;", $string);
return strip_tags($string);
}
/**
* Returns true if passed $value is numeric
*
* @param $value
* @return bool
*/
function my_is_numeric($value) {
$american = preg_match ("/^(-){0,1}([0-9]+)(,[0-9][0-9][0-9])*([.][0-9]){0,1}([0-9]*)$/" ,$value) == 1;
$world = preg_match ("/^(-){0,1}([0-9]+)(.[0-9][0-9][0-9])*([,][0-9]){0,1}([0-9]*)$/" ,$value) == 1;
return ($american or $world);
}
function spss_export_data ($na = null) {
global $length_data;
// Build array that has to be returned
$fields = spss_fieldmap();
//Now get the query string with all fields to export
$query = spss_getquery();
$result=db_execute_num($query) or safe_die("Couldn't get results<br />$query<br />".$connect->ErrorMsg()); //Checked
$num_fields = $result->FieldCount();
while ($row = $result->FetchRow()) {
$fieldno = 0;
while ($fieldno < $num_fields)
{
if ($fields[$fieldno]['SPSStype']=='DATETIME23.2'){
#convert mysql datestamp (yyyy-mm-dd hh:mm:ss) to SPSS datetime (dd-mmm-yyyy hh:mm:ss) format
if (isset($row[$fieldno]))
{
list( $year, $month, $day, $hour, $minute, $second ) = split( '([^0-9])', $row[$fieldno] );
if ($year != '' && (int)$year >= 1970)
{
echo "'".date('d-m-Y H:i:s', mktime( $hour, $minute, $second, $month, $day, $year ) )."'";
} else
{
echo ($na);
}
} else
{
echo ($na);
}
} else if ($fields[$fieldno]['LStype'] == 'Y')
{
if ($row[$fieldno] == 'Y') // Yes/No Question Type
{
echo( "'1'");
} else if ($row[$fieldno] == 'N'){
echo( "'2'");
} else {
echo($na);
}
} else if ($fields[$fieldno]['LStype'] == 'G') //Gender
{
if ($row[$fieldno] == 'F')
{
echo( "'1'");
} else if ($row[$fieldno] == 'M'){
echo( "'2'");
} else {
echo($na);
}
} else if ($fields[$fieldno]['LStype'] == 'C') //Yes/No/Uncertain
{
if ($row[$fieldno] == 'Y')
{
echo( "'1'");
} else if ($row[$fieldno] == 'N'){
echo( "'2'");
} else if ($row[$fieldno] == 'U'){
echo( "'3'");
} else {
echo($na);
}
} else if ($fields[$fieldno]['LStype'] == 'E') //Increase / Same / Decrease
{
if ($row[$fieldno] == 'I')
{
echo( "'1'");
} else if ($row[$fieldno] == 'S'){
echo( "'2'");
} else if ($row[$fieldno] == 'D'){
echo( "'3'");
} else {
echo($na);
}
} elseif (($fields[$fieldno]['LStype'] == 'P' || $fields[$fieldno]['LStype'] == 'M') && (substr($fields[$fieldno]['code'],-7) != 'comment' && substr($fields[$fieldno]['code'],-5) != 'other'))
{
if ($row[$fieldno] == 'Y')
{
echo("'1'");
} else
{
echo("'0'");
}
} elseif (!$fields[$fieldno]['hide']) {
$strTmp=mb_substr(strip_tags_full($row[$fieldno]), 0, $length_data);
if (trim($strTmp) != ''){
$strTemp=str_replace(array("'","\n","\r"),array("''",' ',' '),trim($strTmp));
/*
* Temp quick fix for replacing decimal dots with comma's
if (my_is_numeric($strTemp)) {
$strTemp = str_replace('.',',',$strTemp);
}
*/
echo "'$strTemp'";
}
else
{
echo $na;
}
}
$fieldno++;
if ($fieldno<$num_fields && !$fields[$fieldno]['hide']) echo ',';
}
echo "\n";
}
}
/**
* Check it the gives field has a labelset and return it as an array if true
*
* @param $field array field from spss_fieldmap
* @return array or false
*/
function spss_getvalues ($field = array()) {
global $surveyid, $dbprefix, $connect, $clang, $language, $length_vallabel;
if (!isset($field['LStype']) || empty($field['LStype'])) return false;
$answers=array();
if (strpos("!LOR",$field['LStype']) !== false) {
if (substr($field['code'],-5) == 'other' || substr($field['code'],-7) == 'comment') {
//We have a comment field, so free text
} else {
$query = "SELECT {$dbprefix}answers.code, {$dbprefix}answers.answer,
{$dbprefix}questions.type FROM {$dbprefix}answers, {$dbprefix}questions WHERE
{$dbprefix}answers.qid = '".$field["qid"]."' and {$dbprefix}questions.language='".$language."' and {$dbprefix}answers.language='".$language."'
and {$dbprefix}questions.qid='".$field['qid']."' ORDER BY sortorder ASC";
$result=db_execute_assoc($query) or safe_die("Couldn't lookup value labels<br />$query<br />".$connect->ErrorMsg()); //Checked
$num_results = $result->RecordCount();
if ($num_results > 0)
{
$displayvaluelabel = 0;
# Build array that has to be returned
for ($i=0; $i < $num_results; $i++)
{
$row = $result->FetchRow();
$answers[] = array('code'=>$row['code'], 'value'=>strip_tags_full(mb_substr($row["answer"],0,$length_vallabel)));
}
}
}
} elseif (strpos("FWZWH1",$field['LStype']) !== false) {
$query = "SELECT {$dbprefix}questions.lid, {$dbprefix}labels.code, {$dbprefix}labels.title from
{$dbprefix}questions, {$dbprefix}labels WHERE {$dbprefix}labels.language='".$language."' and
{$dbprefix}questions.language='".$language."' and
{$dbprefix}questions.qid ='".$field["qid"]."' and {$dbprefix}questions.lid={$dbprefix}labels.lid ORDER BY sortorder ASC";
$result=db_execute_assoc($query) or safe_die("Couldn't get labels<br />$query<br />".$connect->ErrorMsg()); //Checked
$num_results = $result->RecordCount();
if ($num_results > 0)
{
for ($i=0; $i < $num_results; $i++)
{
$row = $result->FetchRow();
$answers[] = array('code'=>$row['code'], 'value'=>strip_tags_full(mb_substr($row["title"],0,$length_vallabel)));
}
}
} elseif ($field['LStype'] == ':') {
$displayvaluelabel = 0;
//Get the labels that could apply!
$qidattributes=getQuestionAttributes($field["qid"]);
if ($maxvalue=arraySearchByKey("multiflexible_max", $qidattributes, "attribute", 1)) {
$maxvalue=$maxvalue['value'];
} else {
$maxvalue=10;
}
if ($minvalue=arraySearchByKey("multiflexible_min", $qidattributes, "attribute", 1)) {
$minvalue=$minvalue['value'];
} else {
$minvalue=1;
}
if ($stepvalue=arraySearchByKey("multiflexible_step", $qidattributes, "attribute", 1)) {
$stepvalue=$stepvalue['value'];
} else {
$stepvalue=1;
}
if (arraySearchByKey("multiflexible_checkbox", $qidattributes, "attribute", 1)) {
$minvalue=0;
$maxvalue=1;
$stepvalue=1;
}
for ($i=$minvalue; $i<=$maxvalue; $i+=$stepvalue)
{
$answers[] = array('code'=>$i, 'value'=>$i);
}
} elseif ($field['LStype'] == 'M' && substr($field['code'],-5) != 'other' && $field['size'] > 0)
{
$answers[] = array('code'=>1, 'value'=>$clang->gT('Yes'));
$answers[] = array('code'=>0, 'value'=>$clang->gT('Not Selected'));
} elseif ($field['LStype'] == "P" && substr($field['code'],-5) != 'other' && substr($field['code'],-7) != 'comment')
{
$answers[] = array('code'=>1, 'value'=>$clang->gT('Yes'));
$answers[] = array('code'=>0, 'value'=>$clang->gT('Not Selected'));
} elseif ($field['LStype'] == "G" && $field['size'] > 0)
{
$answers[] = array('code'=>1, 'value'=>$clang->gT('Female'));
$answers[] = array('code'=>2, 'value'=>$clang->gT('Male'));
} elseif ($field['LStype'] == "Y" && $field['size'] > 0)
{
$answers[] = array('code'=>1, 'value'=>$clang->gT('Yes'));
$answers[] = array('code'=>2, 'value'=>$clang->gT('No'));
} elseif ($field['LStype'] == "C" && $field['size'] > 0)
{
$answers[] = array('code'=>1, 'value'=>$clang->gT('Yes'));
$answers[] = array('code'=>2, 'value'=>$clang->gT('No'));
$answers[] = array('code'=>3, 'value'=>$clang->gT('Uncertain'));
} elseif ($field['LStype'] == "E" && $field['size'] > 0)
{
$answers[] = array('code'=>1, 'value'=>$clang->gT('Increase'));
$answers[] = array('code'=>2, 'value'=>$clang->gT('Same'));
$answers[] = array('code'=>3, 'value'=>$clang->gT('Decrease'));
}
if (count($answers)>0) {
//check the max width of the answers
$size = 0;
$spssType = 'F'; //Try if we can use num and use alpha as fallback
$size = 1;
foreach ($answers as $answer) {
$len = mb_strlen($answer['code']);
if ($len>$size) $size = $len;
if ($spssType =='F' && (my_is_numeric($answer['code'])===false || $size>16)) $spssType='A';
}
$answers['size'] = $size;
$answers['SPSStype'] = $spssType;
return $answers;
} else {
return false;
}
}
/**
* Creates a fieldmap with all information necessary to output the fields
*
* @param $prefix string prefix for the variable ID
* @return array
*/
function spss_fieldmap($prefix = 'V') {
global $surveyid, $dbprefix, $typeMap, $connect, $clang;
global $surveyprivate, $tokensexist, $language;
$fieldmap = createFieldMap($surveyid, 'full'); //Create a FULL fieldmap
#See if tokens are being used
$tokensexist = tokenTableExists($surveyid);
#Lookup the names of the attributes
$query="SELECT sid, private, language FROM {$dbprefix}surveys WHERE sid=$surveyid";
$result=db_execute_assoc($query) or safe_die("Couldn't count fields<br />$query<br />".$connect->ErrorMsg()); //Checked
$num_results = $result->RecordCount();
$num_fields = $num_results;
# Build array that has to be returned
for ($i=0; $i < $num_results; $i++) {
$row = $result->FetchRow();
$surveyprivate=$row['private'];
$language=$row['language'];
}
$fieldno=0;
$fields=array();
if (isset($tokensexist) && $tokensexist == true && $surveyprivate == 'N') {
$tokenattributes=GetTokenFieldsAndNames($surveyid,false);
foreach ($tokenattributes as $attributefield=>$attributedescription)
{
//Drop the token field, since it is in the survey too
if($attributefield!='token') {
$fieldno++;
$fields[] = array('id'=>"$prefix$fieldno",'name'=>mb_substr($attributefield, 0, 8),
'qid'=>0,'code'=>'','SPSStype'=>'A','LStype'=>'Undef',
'VariableLabel'=>$attributedescription,'sql_name'=>$attributefield,'size'=>'100',
'title'=>$attributefield,'hide'=>0);
}
}
}
$tempArray = array();
$fieldnames = array_values($connect->MetaColumnNames("{$dbprefix}survey_$surveyid", true));
$num_results = count($fieldnames);
$num_fields = $num_results;
$diff = 0;
$noQID = Array('id', 'token', 'datestamp', 'submitdate', 'startdate', 'startlanguage', 'ipaddr', 'refurl');
# Build array that has to be returned
for ($i=0; $i < $num_results; $i++) {
#Conditions for SPSS fields:
# - Length may not be longer than 8 characters
# - Name may not begin with a digit
$fieldname = $fieldnames[$i];
$fieldtype = '';
$ftype='';
$val_size = 1;
$hide = 0;
$export_scale = '';
$code='';
#Determine field type
if ($fieldname=='submitdate' || $fieldname=='startdate' || $fieldname == 'datestamp') {
$fieldtype = 'DATETIME23.2';
} elseif ($fieldname=='startlanguage') {
$fieldtype = 'A';
$val_size = 19;
} elseif ($fieldname=='token') {
$fieldtype = 'A';
$val_size = 16;
} elseif ($fieldname=='id') {
$fieldtype = 'F';
$val_size = 7; //Arbitrarilty restrict to 9,999,999 (7 digits) responses/survey
} elseif ($fieldname == 'ipaddr') {
$fieldtype = 'A';
$val_size = '15';
} elseif ($fieldname == 'refurl') {
$fieldtype = 'A';
$val_size = 255;
}
#Get qid (question id)
if (in_array($fieldname, $noQID) || substr($fieldname,0,10)=='attribute_'){
$qid = 0;
$varlabel = $fieldname;
$ftitle = $fieldname;
} else{
//GET FIELD DATA
$fielddata=arraySearchByKey($fieldname, $fieldmap, 'fieldname', 1);
if (count($fielddata)==0) {
//Field in database but no longer in survey... how is this possible?
//@TODO: think of a fix.
} else {
$qid=$fielddata['qid'];
$ftype=$fielddata['type'];
$fsid=$fielddata['sid'];
$fgid=$fielddata['gid'];
$code=mb_substr($fielddata['fieldname'],strlen($fsid."X".$fgid."X".$qid));
$varlabel=$fielddata['question'];
$ftitle=$fielddata['title'];
if (!is_null($code) && $code<>"" ) $ftitle .= "_$code";
if (isset($typeMap[$ftype]['size'])) $val_size = $typeMap[$ftype]['size'];
if($fieldtype == '') $fieldtype = $typeMap[$ftype]['SPSStype'];
if (isset($typeMap[$ftype]['hide'])) {
$hide = $typeMap[$ftype]['hide'];
$diff++;
}
//Get default scale for this type
if (isset($typeMap[$ftype]['Scale'])) $export_scale = $typeMap[$ftype]['Scale'];
//But allow override
$aQuestionAttribs = getQAttributes($qid);
if (isset($aQuestionAttribs['scale_export'])) $export_scale = $aQuestionAttribs['scale_export'];
}
}
$fieldno++;
$fid = $fieldno - $diff;
$lsLong = isset($typeMap[$ftype]["name"])?$typeMap[$ftype]["name"]:$ftype;
$tempArray = array('id'=>"$prefix$fid",'name'=>mb_substr($fieldname, 0, 8),
'qid'=>$qid,'code'=>$code,'SPSStype'=>$fieldtype,'LStype'=>$ftype,"LSlong"=>$lsLong,
'ValueLabels'=>'','VariableLabel'=>$varlabel,"sql_name"=>$fieldname,"size"=>$val_size,
'title'=>$ftitle,'hide'=>$hide,'scale'=>$export_scale);
//Now check if we have to retrieve value labels
$answers = spss_getvalues($tempArray);
if (is_array($answers)) {
//Ok we have answers
if (isset($answers['size'])) {
$tempArray['size'] = $answers['size'];
unset($answers['size']);
}
if (isset($answers['SPSStype'])) {
$tempArray['SPSStype'] = $answers['SPSStype'];
unset($answers['SPSStype']);
}
$tempArray['answers'] = $answers;
}
$fields[] = $tempArray;
}
return $fields;
}
/**
* Creates a query string with all fields for the export
*
* @return string
*/
function spss_getquery() {
global $surveyprivate, $dbprefix, $surveyid, $tokensexist;
#See if tokens are being used
if (isset($tokensexist) && $tokensexist == true && $surveyprivate == 'N') {
$query="SELECT ";
$tokenattributes=GetTokenFieldsAndNames($surveyid,false);
foreach ($tokenattributes as $attributefield=>$attributedescription) {
//Drop the token field, since it is in the survey too
if($attributefield!='token') {
$query .= "{$dbprefix}tokens_$surveyid.$attributefield, ";
}
}
$query .= "{$dbprefix}survey_$surveyid.*
FROM {$dbprefix}survey_$surveyid
LEFT JOIN {$dbprefix}tokens_$surveyid ON {$dbprefix}survey_$surveyid.token = {$dbprefix}tokens_$surveyid.token";
} else {
$query = "SELECT *
FROM {$dbprefix}survey_$surveyid";
}
switch (incompleteAnsFilterstate()) {
case 'inc':
//Inclomplete answers only
$query .= ' WHERE submitdate is null ';
break;
case 'filter':
//Inclomplete answers only
$query .= ' WHERE submitdate is not null ';
break;
}
return $query;
}
?>

View File

@@ -0,0 +1,244 @@
<?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: export_data_r.php 7315 2009-07-14 11:12:04Z mennodekker $
*/
// Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB
/*
* The SPSS DATA LIST / BEGIN DATA parser is rather simple minded, the number after the type
* specifier identifies the field width (maximum number of characters to scan)
* It will stop short of that number of characters, honouring quote delimited
* space separated strings, however if the width is too small the remaining data in the current
* line becomes part of the next column. Since we want to restrict this script to ONE scan of
* the data (scan & output at same time), the information needed to construct the
* DATA LIST is held in the $fields array, while the actual data is written to a
* to a temporary location, updating length (size) values in the $fields array as
* the tmp file is generated (uses @fwrite's return value rather than strlen).
* Final output renders $fields to a DATA LIST, and then stitches in the tmp file data.
*
* Optimization opportunities remain in the VALUE LABELS section, which runs a query / column
*/
$length_varlabel = '255'; // Set the max text length of Variable Labels
$headerComment = '';
$tempFile = '';
include_once('login_check.php');
//for scale 1=nominal, 2=ordinal, 3=scale
$typeMap = array(
'5'=>Array('name'=>'5 Point Choice','size'=>1,'SPSStype'=>'F','Scale'=>3),
'B'=>Array('name'=>'Array (10 Point Choice)','size'=>1,'SPSStype'=>'F','Scale'=>3),
'A'=>Array('name'=>'Array (5 Point Choice)','size'=>1,'SPSStype'=>'F','Scale'=>3),
'F'=>Array('name'=>'Array (Flexible Labels)','size'=>1,'SPSStype'=>'F'),
'1'=>Array('name'=>'Array (Flexible Labels) Dual Scale','size'=>1,'SPSStype'=>'F'),
'H'=>Array('name'=>'Array (Flexible Labels) by Column','size'=>1,'SPSStype'=>'F'),
'E'=>Array('name'=>'Array (Increase, Same, Decrease)','size'=>1,'SPSStype'=>'F','Scale'=>2),
'C'=>Array('name'=>'Array (Yes/No/Uncertain)','size'=>1,'SPSStype'=>'F'),
'X'=>Array('name'=>'Boilerplate Question','size'=>1,'SPSStype'=>'A','hide'=>1),
'D'=>Array('name'=>'Date','size'=>10,'SPSStype'=>'SDATE'),
'G'=>Array('name'=>'Gender','size'=>1,'SPSStype'=>'F'),
'U'=>Array('name'=>'Huge Free Text','size'=>1,'SPSStype'=>'A'),
'I'=>Array('name'=>'Language Switch','size'=>1,'SPSStype'=>'A'),
'!'=>Array('name'=>'List (Dropdown)','size'=>1,'SPSStype'=>'F'),
'W'=>Array('name'=>'List (Flexible Labels) (Dropdown)','size'=>1,'SPSStype'=>'F'),
'Z'=>Array('name'=>'List (Flexible Labels) (Radio)','size'=>1,'SPSStype'=>'F'),
'L'=>Array('name'=>'List (Radio)','size'=>1,'SPSStype'=>'F'),
'O'=>Array('name'=>'List With Comment','size'=>1,'SPSStype'=>'F'),
'T'=>Array('name'=>'Long free text','size'=>1,'SPSStype'=>'A'),
'K'=>Array('name'=>'Multiple Numerical Input','size'=>1,'SPSStype'=>'F'),
'M'=>Array('name'=>'Multiple Options','size'=>1,'SPSStype'=>'F'),
'P'=>Array('name'=>'Multiple Options With Comments','size'=>1,'SPSStype'=>'F'),
'Q'=>Array('name'=>'Multiple Short Text','size'=>1,'SPSStype'=>'F'),
'N'=>Array('name'=>'Numerical Input','size'=>3,'SPSStype'=>'F','Scale'=>3),
'R'=>Array('name'=>'Ranking','size'=>1,'SPSStype'=>'F'),
'S'=>Array('name'=>'Short free text','size'=>1,'SPSStype'=>'F'),
'Y'=>Array('name'=>'Yes/No','size'=>1,'SPSStype'=>'F'),
':'=>Array('name'=>'Multi flexi numbers','size'=>1,'SPSStype'=>'F','Scale'=>3),
';'=>Array('name'=>'Multi flexi text','size'=>1,'SPSStype'=>'A'),
);
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($subaction))
{
$exportroutput = browsemenubar($clang->gT('Export results'));
$exportroutput .= "<br />\n";
$exportroutput .= "<div class='header'>".$clang->gT("Export result data to R")."</div>\n";
$exportroutput .= "<p style='width:100%;'><ul style='width:300px;margin:0 auto;'><li><a href='$scriptname?action=exportr&amp;sid=$surveyid&amp;subaction=dlstructure'>".$clang->gT("Export R syntax file")."</a></li><li>"
."<a href='$scriptname?action=exportr&amp;sid=$surveyid&amp;subaction=dldata'>".$clang->gT("Export .csv data file")."</a></li></ul></p><br />\n"
."<h3>".$clang->gT("Instructions for the impatient")."</h3>"
."<ol style='width:500px;margin:0 auto; font-size:8pt;'>"
."<li>".$clang->gT("Download the data and the syntax file.")."</li>"
."<li>".$clang->gT("Save both of them on the R working directory (use getwd() and setwd() on the R command window to get and set it)").".</li>"
."<li>".$clang->gT("digit: source(\"Surveydata_syntax.R\", encoding = \"UTF-8\") on the R command window")."</li>"
."</ol><br />"
.$clang->gT("Your data should be imported now, the data.frame is named \"data\", the variable.labels are attributes of data (\"attributes(data)\$variable.labels\"), like for foreign:read.spss.")
."<table><tr><td>";
} else {
// Get Base Language:
$language = GetBaseLanguageFromSurveyID($surveyid);
$clang = new limesurvey_lang($language);
require_once ("export_data_functions.php");
}
if ($subaction=='dldata') {
header("Content-Type: application/download; charset=utf-8");
header("Content-Disposition: attachment; filename=survey_".$surveyid."_data_file.csv");
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
sendcacheheaders();
$na = "\"\"";
spss_export_data($na);
exit;
}
if ($subaction=='dlstructure') {
header("Content-Type: application/download; charset=utf-8");
header("Content-Disposition: attachment; filename=Surveydata_syntax.R");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
sendcacheheaders();
// Build array that has to be returned
$fields = spss_fieldmap();
//Now get the query string with all fields to export
$query = spss_getquery();
$result=db_execute_num($query) or safe_die("Couldn't get results<br />$query<br />".$connect->ErrorMsg()); //Checked
$num_fields = $result->FieldCount();
//Now we check if we need to adjust the size of the field or the type of the field
while ($row = $result->FetchRow()) {
$fieldno = 0;
while ($fieldno < $num_fields)
{
//Performance improvement, don't recheck fields that have valuelabels
if (!isset($fields[$fieldno]['answers'])) {
$strTmp=mb_substr(strip_tags_full($row[$fieldno]), 0, $length_data);
$len = mb_strlen($strTmp);
if($len > $fields[$fieldno]['size']) $fields[$fieldno]['size'] = $len;
if (trim($strTmp) != ''){
if ($fields[$fieldno]['SPSStype']=='F' && (my_is_numeric($strTmp)===false || $fields[$fieldno]['size']>16))
{
$fields[$fieldno]['SPSStype']='A';
}
}
}
$fieldno++;
}
}
/**
* End of DATA print out
*
* Now $fields contains accurate length data, and the DATA LIST can be rendered -- then the contents of the temp file can
* be sent to the client.
*/
echo $headerComment;
echo "data=read.table(\"survey_".$surveyid."_data_file.csv\", sep=\",\", quote = \"'\", na.strings=\"\")\n names(data)=paste(\"V\",1:dim(data)[2],sep=\"\")\n";
foreach ($fields as $field){
if($field['SPSStype'] == 'DATETIME23.2') $field['size']='';
if($field['LStype'] == 'N' || $field['LStype']=='K') {
$field['size'].='.'.($field['size']-1);
}
switch ($field['SPSStype']) {
case 'F':
$type="numeric";
break;
case 'A':
$type="character";
break;
case 'DATETIME23.2':
case 'SDATE':
$type="character";
//@TODO set $type to format for date
break;
}
if (!$field['hide']) echo " data[,which(names(data)==\"" . $field['id'] . "\")]=as.$type(data[,which(names(data)==\"" . $field['id'] . "\")])\n";
}
//Create the variable labels:
echo "#Define Variable Properties.\n";
foreach ($fields as $field) {
if (!$field['hide']) echo 'attributes(data)$variable.labels[which(names(data)=="' . $field['id'] . '")]="' . addslashes(strip_tags_full(mb_substr($field['VariableLabel'],0,$length_varlabel))) . '"' . "\n";
}
// Create our Value Labels!
echo "#Define Value labels.\n";
foreach ($fields as $field) {
if (isset($field['answers'])) {
$answers = $field['answers'];
//print out the value labels!
// data$V14=factor(data$V14,levels=c(1,2,3),labels=c("Yes","No","Uncertain"))
echo 'data$' . $field["id"] . '=factor(data$' . $field["id"] . ',levels=c(';
$str="";
foreach ($answers as $answer) {
if ($field['SPSStype']=="F" && my_is_numeric($answer['code'])) {
$str .= ",{$answer['code']}";
} else {
$str .= ",\"{$answer['code']}\"";
}
}
$str = mb_substr($str,1);
echo $str . '),labels=c(';
$str="";
foreach ($answers as $answer) {
$str .= ",\"{$answer['value']}\"";
}
$str = mb_substr($str,1);
if($field['scale']!=='' && $field['scale'] == 2 ) {
$scale = ",ordered=TRUE";
} else {
$scale = "";
}
echo "$str)$scale)\n";
}
}
//Rename the Variables (in case somethings goes wrong, we still have the OLD values
$errors = "";
echo "v.names=c(";
foreach ($fields as $field){
if (isset($field['sql_name'])) {
$ftitle = $field['title'];
if (!preg_match ("/^([a-z]|[A-Z])+.*$/", $ftitle)) {
$ftitle = "q_" . $ftitle;
}
$ftitle = str_replace(array("-",":",";","!"), array("_hyph_","_dd_","_dc_","_excl_"), $ftitle);
if (!$field['hide']) {
if ($ftitle != $field['title']) $errors .= "# Variable name was incorrect and was changed from {$field['title']} to $ftitle .\n";
echo "\"". $ftitle . "\",";
}
}
}
echo "NA); names(data)= v.names[-length(v.names)]\nprint(str(data))\n";
echo $errors;
exit;
}
?>

View File

@@ -0,0 +1,241 @@
<?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: export_data_spss.php 7175 2009-06-25 11:06:45Z mennodekker $
*/
// Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB
/*
* The SPSS DATA LIST / BEGIN DATA parser is rather simple minded, the number after the type
* specifier identifies the field width (maximum number of characters to scan)
* It will stop short of that number of characters, honouring quote delimited
* space separated strings, however if the width is too small the remaining data in the current
* line becomes part of the next column. Since we want to restrict this script to ONE scan of
* the data (scan & output at same time), the information needed to construct the
* DATA LIST is held in the $fields array, while the actual data is written to a
* to a temporary location, updating length (size) values in the $fields array as
* the tmp file is generated (uses @fwrite's return value rather than strlen).
* Final output renders $fields to a DATA LIST, and then stitches in the tmp file data.
*
* Optimization opportunities remain in the VALUE LABELS section, which runs a query / column
*/
$length_varlabel = '255'; // Set the max text length of Variable Labels
$headerComment = '';
$tempFile = '';
include_once('login_check.php');
//for scale 1=nominal, 2=ordinal, 3=scale
$typeMap = array(
'5'=>Array('name'=>'5 Point Choice','size'=>1,'SPSStype'=>'F','Scale'=>3),
'B'=>Array('name'=>'Array (10 Point Choice)','size'=>1,'SPSStype'=>'F','Scale'=>3),
'A'=>Array('name'=>'Array (5 Point Choice)','size'=>1,'SPSStype'=>'F','Scale'=>3),
'F'=>Array('name'=>'Array (Flexible Labels)','size'=>1,'SPSStype'=>'F'),
'1'=>Array('name'=>'Array (Flexible Labels) Dual Scale','size'=>1,'SPSStype'=>'F'),
'H'=>Array('name'=>'Array (Flexible Labels) by Column','size'=>1,'SPSStype'=>'F'),
'E'=>Array('name'=>'Array (Increase, Same, Decrease)','size'=>1,'SPSStype'=>'F','Scale'=>2),
'C'=>Array('name'=>'Array (Yes/No/Uncertain)','size'=>1,'SPSStype'=>'F'),
'X'=>Array('name'=>'Boilerplate Question','size'=>1,'SPSStype'=>'A','hide'=>1),
'D'=>Array('name'=>'Date','size'=>10,'SPSStype'=>'SDATE'),
'G'=>Array('name'=>'Gender','size'=>1,'SPSStype'=>'F'),
'U'=>Array('name'=>'Huge Free Text','size'=>1,'SPSStype'=>'A'),
'I'=>Array('name'=>'Language Switch','size'=>1,'SPSStype'=>'A'),
'!'=>Array('name'=>'List (Dropdown)','size'=>1,'SPSStype'=>'F'),
'W'=>Array('name'=>'List (Flexible Labels) (Dropdown)','size'=>1,'SPSStype'=>'F'),
'Z'=>Array('name'=>'List (Flexible Labels) (Radio)','size'=>1,'SPSStype'=>'F'),
'L'=>Array('name'=>'List (Radio)','size'=>1,'SPSStype'=>'F'),
'O'=>Array('name'=>'List With Comment','size'=>1,'SPSStype'=>'F'),
'T'=>Array('name'=>'Long free text','size'=>1,'SPSStype'=>'A'),
'K'=>Array('name'=>'Multiple Numerical Input','size'=>1,'SPSStype'=>'F'),
'M'=>Array('name'=>'Multiple Options','size'=>1,'SPSStype'=>'F'),
'P'=>Array('name'=>'Multiple Options With Comments','size'=>1,'SPSStype'=>'F'),
'Q'=>Array('name'=>'Multiple Short Text','size'=>1,'SPSStype'=>'F'),
'N'=>Array('name'=>'Numerical Input','size'=>3,'SPSStype'=>'F','Scale'=>3),
'R'=>Array('name'=>'Ranking','size'=>1,'SPSStype'=>'F'),
'S'=>Array('name'=>'Short free text','size'=>1,'SPSStype'=>'F'),
'Y'=>Array('name'=>'Yes/No','size'=>1,'SPSStype'=>'F'),
':'=>Array('name'=>'Multi flexi numbers','size'=>1,'SPSStype'=>'F','Scale'=>3),
';'=>Array('name'=>'Multi flexi text','size'=>1,'SPSStype'=>'A'),
);
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($subaction))
{
$exportspssoutput = browsemenubar($clang->gT('Export results'));
$exportspssoutput .= "<br />\n";
$exportspssoutput .= "<div class='header'>".$clang->gT("Export result data to SPSS")."</div>\n";
$exportspssoutput .= "<p style='width:100%;'><ul style='width:300px;margin:0 auto;'><li><a href='$scriptname?action=exportspss&amp;sid=$surveyid&amp;subaction=dlstructure'>".$clang->gT("Export SPSS syntax file")."</a></li><li>"
."<a href='$scriptname?action=exportspss&amp;sid=$surveyid&amp;subaction=dldata'>".$clang->gT("Export SPSS data file")."</a></li></ul></p><br />\n"
."<h3>".$clang->gT("Instructions for the impatient")."</h3>"
."<ol style='width:500px;margin:0 auto; font-size:8pt;'>"
."<li>".$clang->gT("Download the data and the syntax file.")."</li>"
."<li>".$clang->gT("Open the syntax file in SPSS in Unicode mode").".</li>"
."<li>".$clang->gT("Edit the 4th line and complete the filename with a full path to the downloaded data file.")."</li>"
."<li>".$clang->gT("Choose 'Run/All' from the menu to run the import.")."</li>"
."</ol><br />"
.$clang->gT("Your data should be imported now.")
."<table><tr><td>";
} else {
// Get Base Language:
$language = GetBaseLanguageFromSurveyID($surveyid);
$clang = new limesurvey_lang($language);
require_once ("export_data_functions.php");
}
if ($subaction=='dldata') {
header("Content-Type: application/download; charset=utf-8");
header("Content-Disposition: attachment; filename=survey_".$surveyid."_SPSS_data_file.dat");
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
sendcacheheaders();
$na = "";
spss_export_data($na);
exit;
}
if ($subaction=='dlstructure') {
header("Content-Type: application/download; charset=utf-8");
header("Content-Disposition: attachment; filename=survey_".$surveyid."_SPSS_syntax_file.sps");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
sendcacheheaders();
// Build array that has to be returned
$fields = spss_fieldmap();
//Now get the query string with all fields to export
$query = spss_getquery();
$result=db_execute_num($query) or safe_die("Couldn't get results<br />$query<br />".$connect->ErrorMsg()); //Checked
$num_fields = $result->FieldCount();
//Now we check if we need to adjust the size of the field or the type of the field
while ($row = $result->FetchRow()) {
$fieldno = 0;
while ($fieldno < $num_fields)
{
//Performance improvement, don't recheck fields that have valuelabels
if (!isset($fields[$fieldno]['answers'])) {
$strTmp=mb_substr(strip_tags_full($row[$fieldno]), 0, $length_data);
$len = mb_strlen($strTmp);
if($len > $fields[$fieldno]['size']) $fields[$fieldno]['size'] = $len;
if (trim($strTmp) != ''){
if ($fields[$fieldno]['SPSStype']=='F' && (my_is_numeric($strTmp)===false || $fields[$fieldno]['size']>16))
{
$fields[$fieldno]['SPSStype']='A';
}
}
}
$fieldno++;
}
}
/**
* End of DATA print out
*
* Now $fields contains accurate length data, and the DATA LIST can be rendered -- then the contents of the temp file can
* be sent to the client.
*/
echo $headerComment;
echo "SET UNICODE=ON.\n"
."GET DATA\n"
."/TYPE=TXT\n"
."/FILE='survey_".$surveyid."_SPSS_data_file.dat'\n"
."/DELCASE=LINE\n"
."/DELIMITERS=\",\"\n"
."/QUALIFIER=\"'\"\n"
."/ARRANGEMENT=DELIMITED\n"
."/FIRSTCASE=1\n"
."/IMPORTCASE=ALL\n"
."/VARIABLES=";
foreach ($fields as $field){
if($field['SPSStype'] == 'DATETIME23.2') $field['size']='';
if($field['SPSStype']=='F' && ($field['LStype'] == 'N' || $field['LStype']=='K')) {
$field['size'].='.'.($field['size']-1);
}
if (!$field['hide']) echo "\n {$field['id']} {$field['SPSStype']}{$field['size']}";
}
echo ".\nCACHE.\n"
."EXECUTE.\n";
//Create the variable labels:
echo "*Define Variable Properties.\n";
foreach ($fields as $field) {
if (!$field['hide']) echo "VARIABLE LABELS " . $field['id'] . " \"" . addslashes(strip_tags_full(mb_substr($field['VariableLabel'],0,$length_varlabel))) . "\".\n";
}
// Create our Value Labels!
echo "*Define Value labels.\n";
foreach ($fields as $field) {
if (isset($field['answers'])) {
$answers = $field['answers'];
//print out the value labels!
echo "VALUE LABELS {$field['id']}\n";
$i=0;
foreach ($answers as $answer) {
$i++;
if ($field['SPSStype']=="F" && my_is_numeric($answer['code'])) {
$str = "{$answer['code']}";
} else {
$str = "\"{$answer['code']}\"";
}
if ($i < count($answers)) {
echo " $str \"{$answer['value']}\"\n";
} else {
echo " $str \"{$answer['value']}\".\n";
}
}
}
}
foreach ($fields as $field){
if($field['scale']!=='') {
switch ($field['scale']) {
case 2:
echo "VARIABLE LEVEL {$field['id']}(ORDINAL).\n";
break;
case 3:
echo "VARIABLE LEVEL {$field['id']}(SCALE).\n";
}
}
}
//Rename the Variables (in case somethings goes wrong, we still have the OLD values
foreach ($fields as $field){
if (isset($field['sql_name']) && $field['hide']===0) {
$ftitle = $field['title'];
if (!preg_match ("/^([a-z]|[A-Z])+.*$/", $ftitle)) {
$ftitle = "q_" . $ftitle;
}
$ftitle = str_replace(array(" ","-",":",";","!","/","\\"), array("_","_hyph_","_dd_","_dc_","_excl_","_fs_","_bs_"), $ftitle);
if ($ftitle != $field['title']) echo "* Variable name was incorrect and was changed from {$field['title']} to $ftitle .\n";
echo "RENAME VARIABLE ( " . $field['id'] . " = " . $ftitle . " ).\n";
}
}
exit;
}
?>

View File

@@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: templates.php 3685 2007-11-22 04:53:18Z jcleeland $
* $Id: export_resources_zip.php 6853 2009-05-15 12:51:09Z c_schmitz $
*/

View File

@@ -1,122 +1,163 @@
<?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: export_structure_csv.php 4646 2008-04-14 18:47:45Z awarren $
*/
// DUMP THE RELATED DATA FOR A SINGLE SURVEY INTO A SQL FILE FOR IMPORTING LATER ON OR ON ANOTHER SURVEY SETUP
// DUMP ALL DATA WITH RELATED SID FROM THE FOLLOWING TABLES
// 1. Surveys
// 2. Surveys Language Table
// 3. Groups
// 4. Questions
// 5. Answers
// 6. Conditions
// 7. Label Sets
// 8. Labels
// 9. Question Attributes
// 10. Assessments
// 11. Quota
// 12. Quota Members
include_once("login_check.php");
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!$surveyid)
{
echo $htmlheader
."<br />\n"
."<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
.$clang->gT("Export Survey")."</strong></td></tr>\n"
."\t<tr><td align='center'>\n"
."<br /><strong><font color='red'>"
.$clang->gT("Error")."</font></strong><br />\n"
.$clang->gT("No SID has been provided. Cannot dump survey")."<br />\n"
."<br /><input type='submit' value='"
.$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n"
."\t</td></tr>\n"
."</table>\n"
."</body></html>\n";
exit;
}
$dumphead = "# LimeSurvey Survey Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped survey from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
//1: Surveys table
$squery = "SELECT * FROM {$dbprefix}surveys WHERE sid=$surveyid";
$sdump = BuildCSVFromQuery($squery);
//2: Surveys Languagsettings table
$slsquery = "SELECT * FROM {$dbprefix}surveys_languagesettings WHERE surveyls_survey_id=$surveyid";
$slsdump = BuildCSVFromQuery($slsquery);
//3: Groups Table
$gquery = "SELECT * FROM {$dbprefix}groups WHERE sid=$surveyid order by gid";
$gdump = BuildCSVFromQuery($gquery);
//4: Questions Table
$qquery = "SELECT * FROM {$dbprefix}questions WHERE sid=$surveyid order by qid";
$qdump = BuildCSVFromQuery($qquery);
//5: Answers table
$aquery = "SELECT {$dbprefix}answers.* FROM {$dbprefix}answers, {$dbprefix}questions WHERE {$dbprefix}answers.language={$dbprefix}questions.language AND {$dbprefix}answers.qid={$dbprefix}questions.qid AND {$dbprefix}questions.sid=$surveyid";
$adump = BuildCSVFromQuery($aquery);
//6: Conditions table
$cquery = "SELECT DISTINCT {$dbprefix}conditions.* FROM {$dbprefix}conditions, {$dbprefix}questions WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid AND {$dbprefix}questions.sid=$surveyid";
$cdump = BuildCSVFromQuery($cquery);
//7: Label Sets
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.lid, label_name, {$dbprefix}labelsets.languages FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE ({$dbprefix}labelsets.lid={$dbprefix}questions.lid or {$dbprefix}labelsets.lid={$dbprefix}questions.lid1) AND type IN ('F', 'H', 'W', 'Z', '1') AND sid=$surveyid";
$lsdump = BuildCSVFromQuery($lsquery);
//8: Labels
$lquery = "SELECT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder,{$dbprefix}labels.language FROM {$dbprefix}labels, {$dbprefix}questions WHERE ({$dbprefix}labels.lid={$dbprefix}questions.lid or {$dbprefix}labels.lid={$dbprefix}questions.lid1) AND type in ('F', 'W', 'H', 'Z', '1') AND sid=$surveyid group by {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder,{$dbprefix}labels.language";
$ldump = BuildCSVFromQuery($lquery);
//9: Question Attributes
$query = "SELECT DISTINCT {$dbprefix}question_attributes.* FROM {$dbprefix}question_attributes, {$dbprefix}questions WHERE {$dbprefix}question_attributes.qid={$dbprefix}questions.qid AND {$dbprefix}questions.sid=$surveyid";
$qadump = BuildCSVFromQuery($query);
//10: Assessments;
$query = "SELECT {$dbprefix}assessments.* FROM {$dbprefix}assessments WHERE {$dbprefix}assessments.sid=$surveyid";
$asdump = BuildCSVFromQuery($query);
//11: Quota;
$query = "SELECT {$dbprefix}quota.* FROM {$dbprefix}quota WHERE {$dbprefix}quota.sid=$surveyid";
$quotadump = BuildCSVFromQuery($query);
//12: Quota Members;
$query = "SELECT {$dbprefix}quota_members.* FROM {$dbprefix}quota_members WHERE {$dbprefix}quota_members.sid=$surveyid";
$quotamemdump = BuildCSVFromQuery($query);
$fn = "limesurvey_survey_$surveyid.csv";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache"); // HTTP/1.0
echo $dumphead, $sdump, $gdump, $qdump, $adump, $cdump, $lsdump, $ldump, $qadump, $asdump, $slsdump, $quotadump, $quotamemdump."\n";
exit;
?>
<?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: export_structure_csv.php 7499 2009-08-20 03:26:29Z jcleeland $
*/
// DUMP THE RELATED DATA FOR A SINGLE SURVEY INTO A SQL FILE FOR IMPORTING LATER ON OR ON ANOTHER SURVEY SETUP
// DUMP ALL DATA WITH RELATED SID FROM THE FOLLOWING TABLES
// 1. Surveys
// 2. Surveys Language Table
// 3. Groups
// 4. Questions
// 5. Answers
// 6. Conditions
// 7. Label Sets
// 8. Labels
// 9. Question Attributes
// 10. Assessments
// 11. Quota
// 12. Quota Members
include_once("login_check.php");
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!$surveyid)
{
echo $htmlheader
."<br />\n"
."<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
.$clang->gT("Export Survey")."</strong></td></tr>\n"
."\t<tr><td align='center'>\n"
."<br /><strong><font color='red'>"
.$clang->gT("Error")."</font></strong><br />\n"
.$clang->gT("No SID has been provided. Cannot dump survey")."<br />\n"
."<br /><input type='submit' value='"
.$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n"
."\t</td></tr>\n"
."</table>\n"
."</body></html>\n";
exit;
}
$dumphead = "# LimeSurvey Survey Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped survey from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
//1: Surveys table
$squery = "SELECT *
FROM {$dbprefix}surveys
WHERE sid=$surveyid";
$sdump = BuildCSVFromQuery($squery);
//2: Surveys Languagsettings table
$slsquery = "SELECT *
FROM {$dbprefix}surveys_languagesettings
WHERE surveyls_survey_id=$surveyid";
$slsdump = BuildCSVFromQuery($slsquery);
//3: Groups Table
$gquery = "SELECT *
FROM {$dbprefix}groups
WHERE sid=$surveyid
ORDER BY gid";
$gdump = BuildCSVFromQuery($gquery);
//4: Questions Table
$qquery = "SELECT *
FROM {$dbprefix}questions
WHERE sid=$surveyid
ORDER BY qid";
$qdump = BuildCSVFromQuery($qquery);
//5: Answers table
$aquery = "SELECT {$dbprefix}answers.*
FROM {$dbprefix}answers, {$dbprefix}questions
WHERE {$dbprefix}answers.language={$dbprefix}questions.language
AND {$dbprefix}answers.qid={$dbprefix}questions.qid
AND {$dbprefix}questions.sid=$surveyid";
$adump = BuildCSVFromQuery($aquery);
//6: Conditions table
$cquery = "SELECT DISTINCT {$dbprefix}conditions.*
FROM {$dbprefix}conditions, {$dbprefix}questions
WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid
AND {$dbprefix}questions.sid=$surveyid";
$cdump = BuildCSVFromQuery($cquery);
//7: Label Sets
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.lid, label_name, {$dbprefix}labelsets.languages
FROM {$dbprefix}labelsets, {$dbprefix}questions
WHERE ({$dbprefix}labelsets.lid={$dbprefix}questions.lid or {$dbprefix}labelsets.lid={$dbprefix}questions.lid1)
AND type IN ('F', 'H', 'W', 'Z', '1', ':', ';')
AND sid=$surveyid";
$lsdump = BuildCSVFromQuery($lsquery);
//8: Labels
$lquery = "SELECT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder,{$dbprefix}labels.language,{$dbprefix}labels.assessment_value
FROM {$dbprefix}labels, {$dbprefix}questions
WHERE ({$dbprefix}labels.lid={$dbprefix}questions.lid or {$dbprefix}labels.lid={$dbprefix}questions.lid1)
AND type in ('F', 'W', 'H', 'Z', '1', ':', ';')
AND sid=$surveyid
GROUP BY {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder,{$dbprefix}labels.language,{$dbprefix}labels.assessment_value";
$ldump = BuildCSVFromQuery($lquery);
//9: Question Attributes
$query = "SELECT {$dbprefix}question_attributes.qaid, {$dbprefix}question_attributes.qid, {$dbprefix}question_attributes.attribute, {$dbprefix}question_attributes.value
FROM {$dbprefix}question_attributes
WHERE {$dbprefix}question_attributes.qid in (select qid from {$dbprefix}questions where sid=$surveyid group by qid)";
$qadump = BuildCSVFromQuery($query);
//10: Assessments;
$query = "SELECT {$dbprefix}assessments.*
FROM {$dbprefix}assessments
WHERE {$dbprefix}assessments.sid=$surveyid";
$asdump = BuildCSVFromQuery($query);
//11: Quota;
$query = "SELECT {$dbprefix}quota.*
FROM {$dbprefix}quota
WHERE {$dbprefix}quota.sid=$surveyid";
$quotadump = BuildCSVFromQuery($query);
//12: Quota Members;
$query = "SELECT {$dbprefix}quota_members.*
FROM {$dbprefix}quota_members
WHERE {$dbprefix}quota_members.sid=$surveyid";
$quotamemdump = BuildCSVFromQuery($query);
//13: Quota languagesettings
$query = "SELECT {$dbprefix}quota_languagesettings.*
FROM {$dbprefix}quota_languagesettings, {$dbprefix}quota
WHERE {$dbprefix}quota.id = {$dbprefix}quota_languagesettings.quotals_quota_id
AND {$dbprefix}quota.sid=$surveyid";
$quotalsdump = BuildCSVFromQuery($query);
$fn = "limesurvey_survey_$surveyid.csv";
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache"); // HTTP/1.0
echo $dumphead, $sdump, $gdump, $qdump, $adump, $cdump, $lsdump, $ldump, $qadump, $asdump, $slsdump, $quotadump, $quotamemdump, $quotalsdump."\n";
exit;
?>

View File

@@ -0,0 +1,170 @@
<?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: export_structure_csv.php 5747 2008-10-07 19:40:33Z c_schmitz $
*/
// DUMP THE RELATED DATA FOR A SINGLE SURVEY INTO A SQL FILE FOR IMPORTING LATER ON OR ON ANOTHER SURVEY SETUP
// DUMP ALL DATA WITH RELATED SID FROM THE FOLLOWING TABLES
// 1. Surveys
// 2. Surveys Language Table
// 3. Groups
// 4. Questions
// 5. Answers
// 6. Conditions
// 7. Label Sets
// 8. Labels
// 9. Question Attributes
// 10. Assessments
// 11. Quota
// 12. Quota Members
include_once("login_check.php");
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!$surveyid)
{
echo $htmlheader
."<br />\n"
."<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
.$clang->gT("Export Survey")."</strong></td></tr>\n"
."\t<tr><td align='center'>\n"
."<br /><strong><font color='red'>"
.$clang->gT("Error")."</font></strong><br />\n"
.$clang->gT("No SID has been provided. Cannot dump survey")."<br />\n"
."<br /><input type='submit' value='"
.$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_top')\">\n"
."\t</td></tr>\n"
."</table>\n"
."</body></html>\n";
exit;
}
$dumphead = "# LimeSurvey Survey Dump\n"
. "# DBVersion $dbversionnumber\n"
. "# This is a dumped survey from the LimeSurvey Script\n"
. "# http://www.limesurvey.org/\n"
. "# Do not change this header!\n";
//1: Surveys table
$squery = "SELECT *
FROM {$dbprefix}surveys
WHERE sid=$surveyid";
$sdump = BuildCSVFromQuery($squery);
//2: Surveys Languagsettings table
$slsquery = "SELECT *
FROM {$dbprefix}surveys_languagesettings
WHERE surveyls_survey_id=$surveyid";
$slsdump = BuildCSVFromQuery($slsquery);
//3: Groups Table
$gquery = "SELECT *
FROM {$dbprefix}groups
WHERE sid=$surveyid
ORDER BY gid";
$gdump = BuildCSVFromQuery($gquery);
//4: Questions Table
$qquery = "SELECT *
FROM {$dbprefix}questions
WHERE sid=$surveyid
ORDER BY qid";
$qdump = BuildCSVFromQuery($qquery);
//5: Answers table
$aquery = "SELECT {$dbprefix}answers.*
FROM {$dbprefix}answers, {$dbprefix}questions
WHERE {$dbprefix}answers.language={$dbprefix}questions.language
AND {$dbprefix}answers.qid={$dbprefix}questions.qid
AND {$dbprefix}questions.sid=$surveyid";
$adump = BuildCSVFromQuery($aquery);
//6: Conditions table
$cquery = "SELECT DISTINCT {$dbprefix}conditions.*
FROM {$dbprefix}conditions, {$dbprefix}questions
WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid
AND {$dbprefix}questions.sid=$surveyid";
$cdump = BuildCSVFromQuery($cquery);
//7: Label Sets
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.lid, label_name, {$dbprefix}labelsets.languages
FROM {$dbprefix}labelsets, {$dbprefix}questions
WHERE ({$dbprefix}labelsets.lid={$dbprefix}questions.lid or {$dbprefix}labelsets.lid={$dbprefix}questions.lid1)
AND type IN ('F', 'H', 'W', 'Z', '1', ':', ';')
AND sid=$surveyid";
$lsdump = BuildCSVFromQuery($lsquery);
//8: Labels
$lquery = "SELECT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder,{$dbprefix}labels.language
FROM {$dbprefix}labels, {$dbprefix}questions
WHERE ({$dbprefix}labels.lid={$dbprefix}questions.lid or {$dbprefix}labels.lid={$dbprefix}questions.lid1)
AND type in ('F', 'W', 'H', 'Z', '1', ':', ';')
AND sid=$surveyid
GROUP BY {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder,{$dbprefix}labels.language";
$ldump = BuildCSVFromQuery($lquery);
//9: Question Attributes
$query = "SELECT DISTINCT {$dbprefix}question_attributes.*
FROM {$dbprefix}question_attributes, {$dbprefix}questions
WHERE {$dbprefix}question_attributes.qid={$dbprefix}questions.qid
AND {$dbprefix}questions.sid=$surveyid";
$qadump = BuildCSVFromQuery($query);
//10: Assessments;
$query = "SELECT {$dbprefix}assessments.*
FROM {$dbprefix}assessments
WHERE {$dbprefix}assessments.sid=$surveyid";
$asdump = BuildCSVFromQuery($query);
//11: Quota;
$query = "SELECT {$dbprefix}quota.*
FROM {$dbprefix}quota
WHERE {$dbprefix}quota.sid=$surveyid";
$quotadump = BuildCSVFromQuery($query);
//12: Quota Members;
$query = "SELECT {$dbprefix}quota_members.*
FROM {$dbprefix}quota_members
WHERE {$dbprefix}quota_members.sid=$surveyid";
$quotamemdump = BuildCSVFromQuery($query);
$fn = "limesurvey_survey_$surveyid.csv";
//header("Content-Type: application/download");
//header("Content-Disposition: attachment; filename=$fn");
//header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
//header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//header("Pragma: cache"); // HTTP/1.0
include("../config.php");
include("remotecontrol/lsrc.config.php");
$lsrcString = $dumphead. $sdump. $gdump. $qdump. $adump. $cdump. $lsdump. $ldump. $qadump. $asdump. $slsdump. $quotadump. $quotamemdump."\n";
//Select title as Filename and save
$surveyTitleSql = "SELECT surveyls_title
FROM {$dbprefix}surveys_languagesettings
WHERE surveyls_survey_id=$surveyid";
$surveyTitleRs = db_execute_assoc($surveyTitleSql);
$surveyTitle = $surveyTitleRs->FetchRow();
file_put_contents("remotecontrol/".$coreDir.$surveyTitle['surveyls_title'].".csv",$lsrcString);
header("Location: $scriptname?sid=$surveyid");
exit;
?>

View File

@@ -416,7 +416,7 @@ while ($Row = $QueryResult->FetchRow())
$question->append_child($response);
break;
case "S": //SHORT FREE TEXT
$response->append_child(create_free("text",get_length($qid,"maximum_chars","240"),""));
$response->append_child(create_free("text",get_length($qid,"text_input_width","240"),""));
$question->append_child($response);
break;
case "T": //LONG FREE TEXT
@@ -502,7 +502,8 @@ while ($Row = $QueryResult->FetchRow())
$response->set_attribute("varName",'datecomp');
$response->append_child(create_free("text",16,""));
$question->append_child($response);
$questionnaire->append_child($section);
}

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: conditions.php 3736 2007-11-30 16:13:55Z lemeur $
* $Id: fck_LimeReplacementFields.php 7161 2009-06-22 19:13:21Z lemeur $
*/
include_once("login_check.php");
@@ -32,19 +32,30 @@ $InsertansUnsupportedtypes=Array(); // Currently all question types are supporte
$replFields=Array();
$isInstertansEnabled=false;
$limereplacementoutput=""
. "<script language=\"javascript\">\n"
. "var oEditor = window.parent.InnerDialogLoaded() ;\n"
. "var dialog = oEditor.FCK ;\n"
. "var FCKLang = oEditor.FCKLang ;\n"
. "var FCKLimeReplacementFieldss = oEditor.FCKLimeReplacementFieldss ;\n"
. "window.onload = function ()\n"
. "{\n"
. "\toEditor.FCKLanguageManager.TranslatePage( document ) ;\n"
. "\tLoadSelected() ;\n"
. "\twindow.parent.SetOkButton( true ) ;\n"
. "}\n"
$limereplacementoutput="<html>\n"
. "\t<head>\n"
. "\t\t<title>LimeReplacementFields</title>\n"
. "\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
. "\t\t<meta content=\"noindex, nofollow\" name=\"robots\">\n"
. "\t\t<script src=\"$fckeditordir/editor/dialog/common/fck_dialog_common.js\" type=\"text/javascript\"></script>\n"
. "\t\t<script src=\"$rooturl/scripts/jquery/jquery.js\" type=\"text/javascript\"></script>\n"
. "\t\t<script language=\"javascript\">\n"
. "\t\t\tvar mydialog = window.parent ;\n"
. "\t\t\tvar oEditor = mydialog.InnerDialogLoaded() ;\n"
. "\t\t\tvar dialog = oEditor.FCK ;\n"
. "\t\t\tvar FCKLang = oEditor.FCKLang ;\n"
. "\t\t\tvar FCKLimeReplacementFieldss = oEditor.FCKLimeReplacementFieldss ;\n"
. "\t\t\$(document).ready(function ()\n"
. "\t\t\t{\n"
. "\t\t\t\toEditor.FCKLanguageManager.TranslatePage( document ) ;\n"
. "\t\t\t\tLoadSelected() ;\n"
. "\t\t\t\tmydialog.SetOkButton( true ) ;\n"
. "\n"
. "\t\t\t\tSelectField( 'cquestions' ) ;\n"
. "\t\t\t});\n"
. "\n";
/**$limereplacementoutput="\n"
. "if (! oEditor.FCKBrowserInfo.IsIE)\n"
. "{\n"
. "\tinnertext = '' + dialog.EditorWindow.getSelection() + '' ;\n"
@@ -52,39 +63,70 @@ $limereplacementoutput=""
. "else\n"
. "{\n"
. "\tinnertext = '' + dialog.EditorDocument.selection.createRange().text + '' ;\n"
. "}\n"
. "\n"
. "function Ok()\n"
. "{\n"
. "\tvar sValue = document.getElementById('cquestions').value ;\n"
. "\tFCKLimeReplacementFieldss.Add( sValue ) ;\n"
. "\treturn true ;\n"
. "}\n"
. "}\n";
**/
$limereplacementoutput .= ""
. "\t\t\tvar eSelected = dialog.Selection.GetSelectedElement() ;\n"
. "\n";
/**
$limereplacementoutput="\n"
. "function LoadSelected()\n"
. "{\n"
. "\tif ( innertext == '' )\n"
. "\t\treturn ;\n"
// . "\tif ( eSelected.tagName == 'SPAN' && eSelected._fckLimeReplacementFields )\n"
. "var replcode=innertext.substring(innertext.indexOf('{')+1,innertext.lastIndexOf('}'));\n"
// . "alert('TIBO=' + replcode);\n"
. "\t\tdocument.getElementById('cquestions').value = replcode;\n"
// . "\telse\n"
// . "\t\teSelected == null ;\n"
. "}\n"
. "</script>\n";
. "}\n";
**/
$limereplacementoutput .= ""
. "\t\t\tfunction LoadSelected()\n"
. "\t\t\t{\n"
. "\t\t\t\tif ( !eSelected )\n"
. "\t\t\t\t\treturn ;\n"
. "\t\t\t\tif ( eSelected.tagName == 'SPAN' && eSelected._fckLimeReplacementFields )\n"
. "\t\t\t\t\t document.getElementById('cquestions').value = eSelected._fckLimeReplacementFields ;\n"
. "\t\t\t\telse\n"
. "\t\t\t\t\teSelected == null ;\n"
. "\t\t\t}\n";
$limereplacementoutput .= "<table><tr><td>";
$limereplacementoutput .= ""
. "\t\t\tfunction Ok()\n"
. "\t\t\t{\n"
. "\t\t\t\tvar sValue = document.getElementById('cquestions').value ;\n"
. "\t\t\t\tFCKLimeReplacementFieldss.Add( sValue ) ;\n"
. "\t\t\t\treturn true ;\n"
. "\t\t\t}\n";
$limereplacementoutput .= ""
. "\t\t\t</script>\n"
. "\t\t</head>\n";
$limereplacementoutput .= "\t<body scroll=\"no\" style=\"OVERFLOW: hidden\">\n"
. "\t\t<table height=\"100%\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">\n"
. "\t\t\t<tr>\n"
. "\t\t\t\t<td>\n";
switch ($fieldtype)
{
case 'survey-desc':
case 'survey-welc':
case 'survey-endtext':
$replFields[]=array('TOKEN:FIRSTNAME',$clang->gT("Firstname from token"));
$replFields[]=array('TOKEN:LASTNAME',$clang->gT("Lastname from token"));
$replFields[]=array('TOKEN:EMAIL',$clang->gT("Email from the token"));
$replFields[]=array('TOKEN:ATTRIBUTE_1',$clang->gT("Attribute_1 from token"));
$replFields[]=array('TOKEN:ATTRIBUTE_2',$clang->gT("Attribute_2 from token"));
$attributes=GetTokenFieldsAndNames($surveyid,true);
foreach ($attributes as $attributefield=>$attributedescription)
{
$replFields[]=array('TOKEN:'.strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"),$attributedescription));
}
$replFields[]=array('EXPIRY',$clang->gT("Survey expiration date (YYYY-MM-DD)"));
$replFields[]=array('EXPIRY-DMY',$clang->gT("Survey expiration date (DD-MM-YYYY)"));
$replFields[]=array('EXPIRY-MDY',$clang->gT("Survey expiration date (MM-DD-YYYY)"));
break;
case 'email-inv':
@@ -99,11 +141,17 @@ switch ($fieldtype)
$replFields[]=array('LASTNAME',$clang->gT("Lastname from token"));
$replFields[]=array('SURVEYNAME',$clang->gT("Name of the survey"));
$replFields[]=array('SURVEYDESCRIPTION',$clang->gT("Description of the survey"));
$replFields[]=array('ATTRIBUTE_1',$clang->gT("Attribute_1 from token"));
$replFields[]=array('ATTRIBUTE_2',$clang->gT("Attribute_2 from token"));
$attributes=GetTokenFieldsAndNames($surveyid,true);
foreach ($attributes as $attributefield=>$attributedescription)
{
$replFields[]=array(strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"),$attributedescription));
}
$replFields[]=array('ADMINNAME',$clang->gT("Name of the survey administrator"));
$replFields[]=array('ADMINEMAIL',$clang->gT("Email address of the survey administrator"));
$replFields[]=array('SURVEYURL',$clang->gT("URL of the survey"));
$replFields[]=array('EXPIRY',$clang->gT("Survey expiration date (YYYY-MM-DD)"));
$replFields[]=array('EXPIRY-DMY',$clang->gT("Survey expiration date (DD-MM-YYYY)"));
$replFields[]=array('EXPIRY-MDY',$clang->gT("Survey expiration date (MM-DD-YYYY)"));
break;
case 'group-desc':
@@ -112,10 +160,21 @@ switch ($fieldtype)
$replFields[]=array('TOKEN:FIRSTNAME',$clang->gT("Firstname from token"));
$replFields[]=array('TOKEN:LASTNAME',$clang->gT("Lastname from token"));
$replFields[]=array('TOKEN:EMAIL',$clang->gT("Email from the token"));
$replFields[]=array('TOKEN:ATTRIBUTE_1',$clang->gT("Attribute_1 from token"));
$replFields[]=array('TOKEN:ATTRIBUTE_2',$clang->gT("Attribute_2 from token"));
$attributes=GetTokenFieldsAndNames($surveyid,true);
foreach ($attributes as $attributefield=>$attributedescription)
{
$replFields[]=array('TOKEN:'.strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"),$attributedescription));
}
$replFields[]=array('EXPIRY',$clang->gT("Survey expiration date (YYYY-MM-DD)"));
$replFields[]=array('EXPIRY-DMY',$clang->gT("Survey expiration date (DD-MM-YYYY)"));
$replFields[]=array('EXPIRY-MDY',$clang->gT("Survey expiration date (MM-DD-YYYY)"));
case 'editanswer':
$isInstertansEnabled=true;
break;
case 'assessment-text':
$replFields[]=array('TOTAL',$clang->gT("Overall assessment score"));
$replFields[]=array('PERC',$clang->gT("Assessment group score"));
break;
}
@@ -178,6 +237,7 @@ if ($isInstertansEnabled===true)
}
break;
case 'editanswer':
case 'copyquestion':
case 'editquestion':
if (empty($gid)) {die("No GID provided.");}
@@ -314,6 +374,40 @@ if ($isInstertansEnabled===true)
} //while
} //if A,B,C,E,F,H
elseif ($rows['type'] == ":" || $rows['type'] == ";") // Multiflexi
{
//Get the LIDs
$fquery = "SELECT * "
."FROM {$dbprefix}labels "
."WHERE lid={$rows['lid']} "
."AND language='".GetBaseLanguageFromSurveyID($surveyid)."' "
."ORDER BY sortorder, code ";
$fresult = db_execute_assoc($fquery);
while ($frow=$fresult->FetchRow())
{
$lids[$frow['code']]=$frow['title'];
}
//Now cycle through the answers
$aquery="SELECT * "
."FROM {$dbprefix}answers "
."WHERE qid={$rows['qid']} "
."AND {$dbprefix}answers.language='".GetBaseLanguageFromSurveyID($surveyid)."' "
."ORDER BY sortorder, "
."answer";
$aresult=db_execute_assoc($aquery) or safe_die ("Couldn't get answers to Array questions<br />$aquery<br />".$connect->ErrorMsg());
while ($arows = $aresult->FetchRow())
{
$shortanswer = strip_tags($arows['answer']);
$shortanswer .= " [{$arows['code']}]";
foreach($lids as $key=>$val)
{
$cquestions[]=array("$shortquestion [$shortanswer [$val]] ", $rows['qid'], $rows['type'], $rows['sid'].$X.$rows['gid'].$X.$rows['qid'].$arows['code']."_".$key,$rows['previouspage']);
}
}
} //TIBO
elseif ($rows['type'] == "R") //Answer Ranking
{
$aquery="SELECT * "
@@ -396,30 +490,33 @@ if ($isInstertansEnabled===true)
if (count($replFields) > 0 || isset($cquestions) )
{
$limereplacementoutput .= "\t\t\t<select name='cquestions' id='cquestions' style='font-family:verdana; background-color: #FFFFFF; font-size:10; border: 0px;width:99%;' size='15' ondblclick='Ok();'>\n";
$limereplacementoutput .= "\t\t\t\t\t<select name='cquestions' id='cquestions' style='font-family:verdana; background-color: #FFFFFF; font-size:10; border: 0px;width:99%;' size='15' ondblclick='Ok();'>\n";
$noselection = false;
}
else
{
$limereplacementoutput = $clang->gT("No replacement variable available for this field");
echo $limereplacementoutput;
return;
$limereplacementoutput .= $clang->gT("No replacement variable available for this field");
//echo $limereplacementoutput;
//return;
$noselection = true;
}
if (count($replFields) > 0)
{
$limereplacementoutput .= "\t\t\t\t<optgroup label='".$clang->gT("Standard Fields")."'>\n";
$limereplacementoutput .= "\t\t\t\t\t\t<optgroup label='".$clang->gT("Standard Fields")."'>\n";
foreach ($replFields as $stdfield)
{
$limereplacementoutput .= "\t\t\t\t<option value='".$stdfield[0]."'";
$limereplacementoutput .= "\t\t\t\t\t\t\t<option value='".$stdfield[0]."'";
$limereplacementoutput .= ">".$stdfield[1]."</option>\n";
}
$limereplacementoutput .= "\t\t\t\t</optgroup>\n";
$limereplacementoutput .= "\t\t\t\t\t\t</optgroup>\n";
}
if (isset($cquestions))
{
$limereplacementoutput .= "\t\t\t\t<optgroup label='".$clang->gT("Previous Answers Fields")."'>\n";
$limereplacementoutput .= "\t\t\t\t\t\t<optgroup label='".$clang->gT("Previous Answers Fields")."'>\n";
foreach ($cquestions as $cqn)
{
$isDisabled="";
@@ -432,36 +529,53 @@ if (isset($cquestions))
$isDisabled=" disabled='disabled'";
}
$limereplacementoutput .= "\t\t\t\t<option value='INSERTANS:$cqn[3]'";
$limereplacementoutput .= "\t\t\t\t\t\t\t<option value='INSERTANS:$cqn[3]'";
$limereplacementoutput .= " $isDisabled >$cqn[0]</option>\n";
}
$limereplacementoutput .= "\t\t\t\t</optgroup>\n";
$limereplacementoutput .= "\t\t\t\t\t\t</optgroup>\n";
}
$limereplacementoutput .= "\t\t\t</select>\n";
$limereplacementoutput .= "</td></tr>\n";
if ($noselection === false)
{
$limereplacementoutput .= "\t\t\t\t\t</select>\n";
}
$limereplacementoutput .= "\t\t\t\t</td>\n"
. "\t\t\t</tr>\n";
if (isset($surveyformat))
{
switch ($surveyformat)
{
case 'A':
$limereplacementoutput .= "<tr><td>\n";
$limereplacementoutput .= "<br /><font color='orange'>".$clang->gT("Some Question have been disabled")."</font>";
$limereplacementoutput .= "<br />".sprintf($clang->gT("Survey Format is %s:"), $clang->gT("All in one"))."<br /><i>".$clang->gT("Only Previous pages answers are available")."</i><br />";
$limereplacementoutput .= "</td></tr>\n";
$limereplacementoutput .= "\t\t\t<tr>\n"
. "\t\t\t\t<td>\n";
$limereplacementoutput .= "\t\t\t\t\t<br />\n"
. "\t\t\t\t\t<font color='orange'>".$clang->gT("Some Question have been disabled")."</font>\n";
$limereplacementoutput .= "\t\t\t\t\t<br />\n"
. "\t\t\t\t\t".sprintf($clang->gT("Survey Format is %s:"), $clang->gT("All in one"))
. "\t\t\t\t\t<br />\n"
. "\t\t\t\t\t<i>".$clang->gT("Only Previous pages answers are available")."</i>\n"
. "\t\t\t\t\t<br />\n";
$limereplacementoutput .= "\t\t\t\t</td>\n"
. "\t\t\t</tr>\n";
break;
case 'G':
$limereplacementoutput .= "<tr><td>\n";
$limereplacementoutput .= "<br /><font color='orange'>".$clang->gT("Some Question have been disabled")."</font>";
$limereplacementoutput .= "<br />".sprintf($clang->gT("Survey mode is set to %s:"), $clang->gT("Group by Group"))."<br/><i>".$clang->gT("Only Previous pages answers are available")."</i><br />"; $limereplacementoutput .= "</td></tr>\n";
$limereplacementoutput .= "\t\t\t<tr>\n"
. "\t\t\t\t<td>\n";
$limereplacementoutput .= "\t\t\t\t\t<br /><font color='orange'>".$clang->gT("Some Question have been disabled")."</font>";
$limereplacementoutput .= "<br />".sprintf($clang->gT("Survey mode is set to %s:"), $clang->gT("Group by Group"))."<br/><i>".$clang->gT("Only Previous pages answers are available")."</i><br />";
$limereplacementoutput .= "\t\t\t\t</td>\n"
. "\t\t\t</tr>\n";
break;
}
}
$limereplacementoutput .= "</table>\n";
$limereplacementoutput .= "\t\t</table>\n"
. "\t</body>\n"
. "</html>";
echo $limereplacementoutput;
exit;
?>

View File

@@ -1,175 +1,182 @@
<?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: grouphandling.php 4973 2008-06-01 14:07:01Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
if ($action == "addgroup")
{
$grplangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$grplangs[] = $baselang;
$grplangs = array_reverse($grplangs);
$newgroupoutput = PrepareEditorScript();
$newgroupoutput .= ""
."<table width='100%' border='0' class='tab-page'><tr>\n"
."\t<td colspan='2' class='settingcaption'>\n\t\t<strong>".$clang->gT("Add Group")."</strong></td>"
."</tr></table>\n";
// $newgroupoutput .="<table width='100%' border='0' class='tab-page'>\n\t<tr><td>\n"
$newgroupoutput .= "<form action='$scriptname' id ='addnewgroupfrom' name='addnewgroupfrom' method='post'>";
$newgroupoutput .="\n"
. '<div class="tab-pane" id="tab-pane-1">';
foreach ($grplangs as $grouplang)
{
$newgroupoutput .= '<div class="tab-page"> <h2 class="tab">'.GetLanguageNameFromCode($grouplang,false);
if ($grouplang==$baselang) {$newgroupoutput .= '('.$clang->gT("Base Language").')';}
$newgroupoutput .= "</h2>"
. "<table width='100%' border='0' class='form2columns'>"
. "\t\t<tr><td align='right'><strong>".$clang->gT("Title").":</strong></td>\n"
. "\t\t<td><input type='text' size='80' maxlength='100' name='group_name_$grouplang' id='group_name_$grouplang' /><font color='red' face='verdana' size='1'> ".$clang->gT("Required")."</font></td></tr>\n"
. "\t<tr><td align='right'><strong>".$clang->gT("Description:")."</strong></td>\n"
. "\t\t<td><textarea cols='80' rows='8' name='description_$grouplang'></textarea>"
. getEditor("group-desc","description_".$grouplang, "[".$clang->gT("Description:", "js")."](".$grouplang.")",$surveyid,'','',$action)
."</td></tr>\n"
. "</table>";
$newgroupoutput.= "\t<table><tr><td colspan='2' align='center'><input type='submit' value='".$clang->gT("Add Group")."' />\n"
. "\t</td></tr></table>\n"
. "\n";
$newgroupoutput.= "</div>\n";
}
$newgroupoutput.= ""
. "\t<input type='hidden' name='action' value='insertnewgroup' />\n"
. "\t<input type='hidden' name='sid' value='$surveyid' />\n"
. "</form>\n";
// Import TAB
$newgroupoutput .= '<div class="tab-page"> <h2 class="tab">'.$clang->gT("Import Group")."</h2>\n";
$newgroupoutput.= ""
. "<form enctype='multipart/form-data' name='importgroup' action='$scriptname' method='post' onsubmit='return validatefilename(this,\"".$clang->gT('Please select a file to import!','js')."\");'>\n"
. "<table width='100%' border='0' class='form2columns'>\n"
. "\t\t<tr>"
. "\t\n"
. "\t\t<td><strong>".$clang->gT("Select CSV File:")."</strong></td>\n"
. "\t\t<td><input name=\"the_file\" type=\"file\" size=\"35\" /></td></tr>\n"
. "\t\t<tr>\t\t<td>".$clang->gT("Convert Resources links ?")."</td>\n"
. "\t\t<td><input name=\"translinksfields\" type=\"checkbox\" /></td></tr>\n"
. "\t<tr><td colspan='2'class='centered'><input type='submit' value='".$clang->gT("Import Group")."' />\n"
. "\t<input type='hidden' name='action' value='importgroup' />\n"
. "\t<input type='hidden' name='sid' value='$surveyid' />\n"
. "\t</td></tr>\n</table></form>\n";
// End Import TABS
$newgroupoutput.= "</div>";
// End of TABS
$newgroupoutput.= "</div>";
$newgroupoutput.= ""
."<script type='text/javascript'>\n"
."<!--\n"
."document.getElementById('group_name_$grouplang').focus();\n"
."//-->\n"
."</script>\n";
}
if ($action == "editgroup")
{
$grplangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$grplangs[] = $baselang;
$grplangs = array_flip($grplangs);
$egquery = "SELECT * FROM ".db_table_name('groups')." WHERE sid=$surveyid AND gid=$gid";
$egresult = db_execute_assoc($egquery);
while ($esrow = $egresult->FetchRow())
{
if(!array_key_exists($esrow['language'], $grplangs)) // Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE.
{
$egquery = "DELETE FROM ".db_table_name('groups')." WHERE sid='{$surveyid}' AND gid='{$gid}' AND language='".$esrow['language']."'";
$egresultD = $connect->Execute($egquery);
} else {
$grplangs[$esrow['language']] = 99;
}
if ($esrow['language'] == $baselang) $basesettings = array('group_name' => $esrow['group_name'],'description' => $esrow['description'],'group_order' => $esrow['group_order']);
}
while (list($key,$value) = each($grplangs))
{
if ($value != 99)
{
$egquery = "INSERT INTO ".db_table_name('groups')." (gid, sid, group_name, description,group_order,language) VALUES ('{$gid}', '{$surveyid}', '{$basesettings['group_name']}', '{$basesettings['description']}','{$basesettings['group_order']}', '{$key}')";
$egresult = $connect->Execute($egquery);
}
}
$egquery = "SELECT * FROM ".db_table_name('groups')." WHERE sid=$surveyid AND gid=$gid AND language='$baselang'";
$egresult = db_execute_assoc($egquery);
$editgroup = PrepareEditorScript();
$editgroup .= "<table width='100%' border='0'>\n\t<tr><td class='settingcaption'>"
. "\t\t".$clang->gT("Edit Group")."</td></tr></table>\n"
. "<form name='editgroup' action='$scriptname' method='post'>\n"
. '<div class="tab-pane" id="tab-pane-1">';
$esrow = $egresult->FetchRow();
$editgroup .= '<div class="tab-page"> <h2 class="tab">'.getLanguageNameFromCode($esrow['language'],false);
$editgroup .= '('.$clang->gT("Base Language").')';
$esrow = array_map('htmlspecialchars', $esrow);
$editgroup .= '</h2>';
$editgroup .= "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Title").":</span>\n"
. "\t\t<span class='settingentry'><input type='text' maxlength='100' size='80' name='group_name_{$esrow['language']}' value=\"{$esrow['group_name']}\" />\n"
. "\t</span></div>\n"
. "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Description:")."</span>\n"
. "\t\t<span class='settingentry'><textarea cols='70' rows='8' name='description_{$esrow['language']}'>{$esrow['description']}</textarea>\n"
. getEditor("group-desc","description_".$esrow['language'], "[".$clang->gT("Description:", "js")."](".$esrow['language'].")",$surveyid,$gid,'',$action)
. "\t</span></div><div class='settingrow'></div></div>"; // THis empty div class is needed for forcing the tabpage border under the button
$egquery = "SELECT * FROM ".db_table_name('groups')." WHERE sid=$surveyid AND gid=$gid AND language!='$baselang'";
$egresult = db_execute_assoc($egquery);
while ($esrow = $egresult->FetchRow())
{
$editgroup .= '<div class="tab-page"> <h2 class="tab">'.getLanguageNameFromCode($esrow['language'],false);
$esrow = array_map('htmlspecialchars', $esrow);
$editgroup .= '</h2>';
$editgroup .= "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Title").":</span>\n"
. "\t\t<span class='settingentry'><input type='text' maxlength='100' size='80' name='group_name_{$esrow['language']}' value=\"{$esrow['group_name']}\" />\n"
. "\t</span></div>\n"
. "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Description:")."</span>\n"
. "\t\t<span class='settingentry'><textarea cols='70' rows='8' name='description_{$esrow['language']}'>{$esrow['description']}</textarea>\n"
. getEditor("group-desc","description_".$esrow['language'], "[".$clang->gT("Description:", "js")."](".$esrow['language'].")",$surveyid,$gid,'',$action)
. "\t</span></div><div class='settingrow'></div></div>"; // THis empty div class is needed for forcing the tabpage border under the button
}
$editgroup .= '</div>';
$editgroup .= "\t<p><input type='submit' class='standardbtn' value='".$clang->gT("Update Group")."' />\n"
. "\t<input type='hidden' name='action' value='updategroup' />\n"
. "\t<input type='hidden' name='sid' value=\"{$surveyid}\" />\n"
. "\t<input type='hidden' name='gid' value='{$gid}' />\n"
. "\t<input type='hidden' name='language' value=\"{$esrow['language']}\" />\n"
. "\t</p>\n"
. "</form>\n";
}
?>
<?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: grouphandling.php 7446 2009-08-11 18:28:47Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
if ($action == "addgroup")
{
$grplangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$grplangs[] = $baselang;
$grplangs = array_reverse($grplangs);
$newgroupoutput = PrepareEditorScript();
$newgroupoutput .= ""
."<table width='100%' border='0' class='tab-page'><tr>\n"
."\t<td colspan='2' class='settingcaption'>\n\t\t<strong>".$clang->gT("Add Group")."</strong></td>"
."</tr></table>\n";
// $newgroupoutput .="<table width='100%' border='0' class='tab-page'>\n\t<tr><td>\n"
$newgroupoutput .="\n"
. '<div class="tab-pane" id="tab-pane-newgroup">';
$newgroupoutput .= "<form action='$scriptname' id ='addnewgroupfrom' name='addnewgroupfrom' method='post' onsubmit=\"if (1==0 ";
foreach ($grplangs as $grouplang)
{
$newgroupoutput .= "|| document.getElementById('group_name_$grouplang').value.length==0 ";
}
$newgroupoutput .=" ) {alert ('".$clang->gT("Error: You have to enter a group title for each language.",'js')."'); return false;}\" ";
foreach ($grplangs as $grouplang)
{
$newgroupoutput .= '<div class="tab-page"> <h2 class="tab">'.GetLanguageNameFromCode($grouplang,false);
if ($grouplang==$baselang) {$newgroupoutput .= '('.$clang->gT("Base Language").')';}
$newgroupoutput .= "</h2>"
. "<table width='100%' border='0' class='form2columns'>"
. "\t\t<tr><td align='right'><strong>".$clang->gT("Title").":</strong></td>\n"
. "\t\t<td><input type='text' size='80' maxlength='100' name='group_name_$grouplang' id='group_name_$grouplang' /><font color='red' face='verdana' size='1'> ".$clang->gT("Required")."</font></td></tr>\n"
. "\t<tr><td align='right'><strong>".$clang->gT("Description:")."</strong></td>\n"
. "\t\t<td><textarea cols='80' rows='8' name='description_$grouplang'></textarea>"
. getEditor("group-desc","description_".$grouplang, "[".$clang->gT("Description:", "js")."](".$grouplang.")",$surveyid,'','',$action)
."</td></tr>\n"
. "</table>";
$newgroupoutput.= "\t<table><tr><td colspan='2' align='center'><input type='submit' value='".$clang->gT("Add Group")."' />\n"
. "\t</td></tr></table>\n"
. "\n";
$newgroupoutput.= "</div>\n";
}
$newgroupoutput.= ""
. "\t<input type='hidden' name='action' value='insertnewgroup' />\n"
. "\t<input type='hidden' name='sid' value='$surveyid' />\n"
. "</form>\n";
// Import TAB
$newgroupoutput .= '<div class="tab-page"> <h2 class="tab">'.$clang->gT("Import Group")."</h2>\n";
$newgroupoutput.= ""
. "<form enctype='multipart/form-data' name='importgroup' action='$scriptname' method='post' onsubmit='return validatefilename(this,\"".$clang->gT('Please select a file to import!','js')."\");'>\n"
. "<table width='100%' border='0' class='form2columns'>\n"
. "\t\t<tr>"
. "\t\n"
. "\t\t<td><strong>".$clang->gT("Select CSV File:")."</strong></td>\n"
. "\t\t<td><input name=\"the_file\" type=\"file\" size=\"35\" /></td></tr>\n"
. "\t\t<tr>\t\t<td>".$clang->gT("Convert resources links?")."</td>\n"
. "\t\t<td><input name=\"translinksfields\" type=\"checkbox\" checked=\"checked\"/></td></tr>\n"
. "\t<tr><td colspan='2'class='centered'><input type='submit' value='".$clang->gT("Import Group")."' />\n"
. "\t<input type='hidden' name='action' value='importgroup' />\n"
. "\t<input type='hidden' name='sid' value='$surveyid' />\n"
. "\t</td></tr>\n</table></form>\n";
// End Import TABS
$newgroupoutput.= "</div>";
// End of TABS
$newgroupoutput.= "</div>";
$newgroupoutput.= ""
."<script type='text/javascript'>\n"
."<!--\n"
."document.getElementById('group_name_$grouplang').focus();\n"
."//-->\n"
."</script>\n";
}
if ($action == "editgroup")
{
$grplangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$grplangs[] = $baselang;
$grplangs = array_flip($grplangs);
$egquery = "SELECT * FROM ".db_table_name('groups')." WHERE sid=$surveyid AND gid=$gid";
$egresult = db_execute_assoc($egquery);
while ($esrow = $egresult->FetchRow())
{
if(!array_key_exists($esrow['language'], $grplangs)) // Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE.
{
$egquery = "DELETE FROM ".db_table_name('groups')." WHERE sid='{$surveyid}' AND gid='{$gid}' AND language='".$esrow['language']."'";
$egresultD = $connect->Execute($egquery);
} else {
$grplangs[$esrow['language']] = 99;
}
if ($esrow['language'] == $baselang) $basesettings = array('group_name' => $esrow['group_name'],'description' => $esrow['description'],'group_order' => $esrow['group_order']);
}
while (list($key,$value) = each($grplangs))
{
if ($value != 99)
{
$egquery = "INSERT INTO ".db_table_name('groups')." (gid, sid, group_name, description,group_order,language) VALUES ('{$gid}', '{$surveyid}', '{$basesettings['group_name']}', '{$basesettings['description']}','{$basesettings['group_order']}', '{$key}')";
$egresult = $connect->Execute($egquery);
}
}
$egquery = "SELECT * FROM ".db_table_name('groups')." WHERE sid=$surveyid AND gid=$gid AND language='$baselang'";
$egresult = db_execute_assoc($egquery);
$editgroup = PrepareEditorScript();
$editgroup .= "<table width='100%' border='0'>\n\t<tr><td class='settingcaption'>"
. "\t\t".$clang->gT("Edit Group")."</td></tr></table>\n"
. "<form name='editgroup' action='$scriptname' method='post'>\n"
. '<div class="tab-pane" id="tab-pane-group-'.$gid.'">';
$esrow = $egresult->FetchRow();
$editgroup .= '<div class="tab-page"> <h2 class="tab">'.getLanguageNameFromCode($esrow['language'],false);
$editgroup .= '('.$clang->gT("Base Language").')';
$esrow = array_map('htmlspecialchars', $esrow);
$editgroup .= '</h2>';
$editgroup .= "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Title").":</span>\n"
. "\t\t<span class='settingentry'><input type='text' maxlength='100' size='80' name='group_name_{$esrow['language']}' value=\"{$esrow['group_name']}\" />\n"
. "\t</span></div>\n"
. "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Description:")."</span>\n"
. "\t\t<span class='settingentry'><textarea cols='70' rows='8' name='description_{$esrow['language']}'>{$esrow['description']}</textarea>\n"
. getEditor("group-desc","description_".$esrow['language'], "[".$clang->gT("Description:", "js")."](".$esrow['language'].")",$surveyid,$gid,'',$action)
. "\t</span></div><div class='settingrow'></div></div>"; // THis empty div class is needed for forcing the tabpage border under the button
$egquery = "SELECT * FROM ".db_table_name('groups')." WHERE sid=$surveyid AND gid=$gid AND language!='$baselang'";
$egresult = db_execute_assoc($egquery);
while ($esrow = $egresult->FetchRow())
{
$editgroup .= '<div class="tab-page"> <h2 class="tab">'.getLanguageNameFromCode($esrow['language'],false);
$esrow = array_map('htmlspecialchars', $esrow);
$editgroup .= '</h2>';
$editgroup .= "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Title").":</span>\n"
. "\t\t<span class='settingentry'><input type='text' maxlength='100' size='80' name='group_name_{$esrow['language']}' value=\"{$esrow['group_name']}\" />\n"
. "\t</span></div>\n"
. "\t<div class='settingrow'><span class='settingcaption'>".$clang->gT("Description:")."</span>\n"
. "\t\t<span class='settingentry'><textarea cols='70' rows='8' name='description_{$esrow['language']}'>{$esrow['description']}</textarea>\n"
. getEditor("group-desc","description_".$esrow['language'], "[".$clang->gT("Description:", "js")."](".$esrow['language'].")",$surveyid,$gid,'',$action)
. "\t</span></div><div class='settingrow'></div></div>"; // THis empty div class is needed for forcing the tabpage border under the button
}
$editgroup .= '</div>';
$editgroup .= "\t<p><input type='submit' class='standardbtn' value='".$clang->gT("Update Group")."' />\n"
. "\t<input type='hidden' name='action' value='updategroup' />\n"
. "\t<input type='hidden' name='sid' value=\"{$surveyid}\" />\n"
. "\t<input type='hidden' name='gid' value='{$gid}' />\n"
. "\t<input type='hidden' name='language' value=\"{$esrow['language']}\" />\n"
. "\t</p>\n"
. "</form>\n";
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,286 +1,295 @@
<?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: htmleditor-functions.php 4916 2008-05-25 17:25:33Z c_schmitz $
*/
//include_once("login_check.php");
//Security Checked: POST/GET/SESSION/DB/returnglobal
function PrepareEditorPopupScript()
{
global $clang,$imagefiles,$homeurl;
$script = "<script type='text/javascript'>\n"
. "<!--\n"
. "var editorwindowsHash = new Object();\n"
. "function find_popup_editor(fieldname)\n"
. "\t{\t\n"
. "\t\tvar window = null;\n"
. "\t\tfor (var key in editorwindowsHash)\n"
. "\t\t{\n"
. "\t\t\tif (key==fieldname && !editorwindowsHash[key].closed)\n"
. "\t\t\t{\n"
. "\t\t\t\twindow = editorwindowsHash[key];\n"
. "\t\t\t\treturn window;\n"
. "\t\t\t}\n"
. "\t\t}\n"
. "\treturn null;\n"
. "\t}\t\n"
. "\n"
. "function start_popup_editor(fieldname, fieldtext, sid, gid, qid, fieldtype, action)\n"
. "\t{\t\n"
// . "\t\tcontrolid = fieldname + '_popupctrl';\n"
. "\t\tcontrolidena = fieldname + '_popupctrlena';\n"
. "\t\tcontroliddis = fieldname + '_popupctrldis';\n"
. "\t\tnumwindows = editorwindowsHash.length;\n"
. "\t\tactivepopup = find_popup_editor(fieldname);\n"
. "\t\tif (activepopup == null)\n"
. "\t\t{\n"
. "\t\t\tdocument.getElementsByName(fieldname)[0].readOnly=true;\n"
. "\t\t\tdocument.getElementsByName(fieldname)[0].className='readonly';\n"
// . "\t\t\tdocument.getElementById(controlid).src='".$imagefiles."/edithtmlpopup_disabled.png';\n"
. "\t\t\tdocument.getElementById(controlidena).style.display='none';\n"
. "\t\t\tdocument.getElementById(controliddis).style.display='';\n"
. "\t\t\tpopup = window.open('".$homeurl."/htmleditor-popup.php?fieldname='+fieldname+'&fieldtext='+fieldtext+'&fieldtype='+fieldtype+'&action='+action+'&sid='+sid+'&gid='+gid+'&qid='+qid+'&lang=".$clang->getlangcode()."','', 'location=no, status=yes, scrollbars=auto, menubar=no, resizable=yes, width=600, height=400');\n"
. "\t\t\teditorwindowsHash[fieldname] = popup;\n"
. "\t\t}\n"
. "\t\telse\n"
. "\t\t{\n"
. "\t\t\tactivepopup.focus();\n"
. "\t\t}\n"
. "\t}\n"
. "\n"
. "function updateFCKeditor(fieldname,value)\n"
. "{\t\n"
. "\tvar mypopup= editorwindowsHash[fieldname];\n"
. "\tif (mypopup)\n"
. "\t{\n"
. "\t\tvar oMyEditor = mypopup.FCKeditorAPI.GetInstance('MyTextarea');\n"
. "\t\tif (oMyEditor) {oMyEditor.SetHTML(value);}\n"
. "\t\tmypopup.focus();\n"
. "\t}\n"
. "}\n"
. "--></script>\n";
return $script;
}
function PrepareEditorInlineScript()
{
global $homeurl, $fckeditordir;
$script ="<script type=\"text/javascript\" src=\"".$fckeditordir."/fckeditor.js\"></script>\n"
. "<script type=\"text/javascript\">\n"
. "<!--\n"
. "function updateFCKeditor(fieldname,value)\n"
. "{\n"
. "\tvar oMyEditor = FCKeditorAPI.GetInstance(fieldname);\n"
. "\toMyEditor.SetHTML(value);\n"
. "}\n"
. "-->\n"
. "</script>\n";
/*** Commented because of inconsistencies
$script .= ""
. "<script type='text/javascript'>\n"
. "<!--\n"
."function FCKeditor_OnComplete( editorInstance )\n"
. "{\n"
. "\teditorInstance.Events.AttachEvent( 'OnBlur' , FCKeditor_OnBlur ) ;\n"
. "\teditorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;\n"
."}\n"
. "function FCKeditor_OnBlur( editorInstance )\n"
. "{\n"
. "\teditorInstance.ToolbarSet.Collapse() ;\n"
. "}\n"
. "function FCKeditor_OnFocus( editorInstance )\n"
. "{\n"
."\teditorInstance.ToolbarSet.Expand() ;\n"
."}\n"
. "--></script>\n";
***/
return $script;
}
function PrepareEditorScript($fieldtype=null)
{
global $defaulthtmleditormode;
if (isset($_SESSION['htmleditormode']) &&
$_SESSION['htmleditormode'] == 'none')
{
return "<script type=\"text/javascript\">\n"
. "<!--\n"
. "function updateFCKeditor(fieldname,value) { return true;}\n"
. "-->\n"
. "</script>\n";
}
if (!isset($_SESSION['htmleditormode']) ||
($_SESSION['htmleditormode'] != 'inline' &&
$_SESSION['htmleditormode'] != 'popup') )
{
$htmleditormode = $defaulthtmleditormode;
}
else
{
$htmleditormode = $_SESSION['htmleditormode'];
}
if ($htmleditormode == 'popup' ||
$fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
return PrepareEditorPopupScript();
}
elseif ($htmleditormode == 'inline')
{
return PrepareEditorInlineScript();
}
else
{
return '';
}
}
function getEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
global $defaulthtmleditormode;
if (isset($_SESSION['htmleditormode']) &&
$_SESSION['htmleditormode'] == 'none')
{
return '';
}
if (!isset($_SESSION['htmleditormode']) ||
($_SESSION['htmleditormode'] != 'inline' &&
$_SESSION['htmleditormode'] != 'popup') )
{
$htmleditormode = $defaulthtmleditormode;
}
else
{
$htmleditormode = $_SESSION['htmleditormode'];
}
if ( ($fieldtype == 'email-inv' ||
$fieldtype == 'email-reg' ||
$fieldtype == 'email-conf' ||
$fieldtype == 'email-rem' ) &&
getEmailFormat($surveyID) != 'html')
{
return '';
}
if ($htmleditormode == 'popup' ||
$fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
return getPopupEditor($fieldtype,$fieldname,$fieldtext, $surveyID,$gID,$qID,$action);
}
elseif ($htmleditormode == 'inline')
{
return getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID,$gID,$qID,$action);
}
else
{
return '';
}
}
function getPopupEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
global $clang, $imagefiles, $homeurl;
$htmlcode = '';
$imgopts = '';
$toolbarname = 'Basic';
if ($fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
$imgopts = "width='14px' height='14px'";
}
$htmlcode .= ""
. "<a href=\"javascript:start_popup_editor('".$fieldname."','".$fieldtext."','".$surveyID."','".$gID."','".$qID."','".$fieldtype."','".$action."')\" id='".$fieldname."_ctrl' title=\"".$clang->gTview("Start HTML Editor in a Popup Window")."\"><img alt=\"".$clang->gT("Start HTML Editor in a Popup Window")."\" id='".$fieldname."_popupctrlena' name='".$fieldname."_popupctrlena' border='0' src='".$imagefiles."/edithtmlpopup.png' $imgopts /><img alt=\"".$clang->gT("Give focus to the HTML Editor Popup Window")."\" id='".$fieldname."_popupctrldis' name='".$fieldname."_popupctrldis' border='0' src='".$imagefiles."/edithtmlpopup_disabled.png' style='display: none' $imgopts align='top'/></a>";
return $htmlcode;
}
function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
global $clang, $imagefiles, $homeurl, $rooturl, $fckeditordir;
$htmlcode = '';
$imgopts = '';
$toolbarname = 'Basic';
$toolbaroption="";
$htmlformatoption="";
if ($fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
$toolbarname = 'LimeSurveyToolbarfull';
$toolbaroption="oFCKeditor_$fieldname.Config[\"ToolbarLocation\"]=\"Out:xToolbar\";\n"
. "oFCKeditor_$fieldname.Config[\"ToolbarStartExpanded\"]=true;\n"
. "oFCKeditor_$fieldname.Config[\"ToolbarCanCollapse\"]=false;\n"
. "oFCKeditor_$fieldname.Height = \"50\"\n";
}
if ( $fieldtype == 'email-inv' ||
$fieldtype == 'email-reg' ||
$fieldtype == 'email-conf' ||
$fieldtype == 'email-rem' )
{
$htmlformatoption = "oFCKeditor_$fieldname.Config[\"FullPage\"]=true;\n";
}
$htmlcode .= ""
. "<script type=\"text/javascript\">\n"
. "var oFCKeditor_$fieldname = new FCKeditor('$fieldname');\n"
. "oFCKeditor_$fieldname.BasePath = '".$fckeditordir."/';\n"
. "oFCKeditor_$fieldname.Config[\"CustomConfigurationsPath\"] = \"".$fckeditordir."/limesurvey-config.js\";\n"
. "oFCKeditor_$fieldname.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";\n"
. "oFCKeditor_$fieldname.Config[\"LimeReplacementFieldsSID\"] = \"".$surveyID."\";\n"
. "oFCKeditor_$fieldname.Config[\"LimeReplacementFieldsGID\"] = \"".$gID."\";\n"
. "oFCKeditor_$fieldname.Config[\"LimeReplacementFieldsQID\"] = \"".$qID."\";\n"
. "oFCKeditor_$fieldname.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";\n"
. "oFCKeditor_$fieldname.Config[\"LimeReplacementFieldsAction\"] = \"".$action."\";\n"
. "oFCKeditor_$fieldname.Config[\"SmileyPath\"] = \"".$rooturl."/upload/images/smiley/msn/\";\n"
. $htmlformatoption
. $toolbaroption;
if ($fieldtype == 'answer' || $fieldtype == 'label')
{
$htmlcode .= ""
. "oFCKeditor_$fieldname.Config[ 'ToolbarLocation' ] = 'Out:xToolbar' ;\n";
}
$htmlcode .= ""
. "oFCKeditor_$fieldname.ToolbarSet = '".$toolbarname."';\n"
. "oFCKeditor_$fieldname.ReplaceTextarea() ;\n"
. '</script>';
return $htmlcode;
}
?>
<?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: htmleditor-functions.php 7076 2009-06-11 20:38:09Z lemeur $
*/
//include_once("login_check.php");
//Security Checked: POST/GET/SESSION/DB/returnglobal
function PrepareEditorPopupScript()
{
global $clang,$imagefiles,$homeurl;
$script = "<script type='text/javascript'>\n"
. "<!--\n"
. "var editorwindowsHash = new Object();\n"
. "function find_popup_editor(fieldname)\n"
. "\t{\t\n"
. "\t\tvar window = null;\n"
. "\t\tfor (var key in editorwindowsHash)\n"
. "\t\t{\n"
. "\t\t\tif (key==fieldname && !editorwindowsHash[key].closed)\n"
. "\t\t\t{\n"
. "\t\t\t\twindow = editorwindowsHash[key];\n"
. "\t\t\t\treturn window;\n"
. "\t\t\t}\n"
. "\t\t}\n"
. "\treturn null;\n"
. "\t}\t\n"
. "\n"
. "function start_popup_editor(fieldname, fieldtext, sid, gid, qid, fieldtype, action)\n"
. "\t{\t\n"
// . "\t\tcontrolid = fieldname + '_popupctrl';\n"
. "\t\tcontrolidena = fieldname + '_popupctrlena';\n"
. "\t\tcontroliddis = fieldname + '_popupctrldis';\n"
. "\t\tnumwindows = editorwindowsHash.length;\n"
. "\t\tactivepopup = find_popup_editor(fieldname);\n"
. "\t\tif (activepopup == null)\n"
. "\t\t{\n"
. "\t\t\tdocument.getElementsByName(fieldname)[0].readOnly=true;\n"
. "\t\t\tdocument.getElementsByName(fieldname)[0].className='readonly';\n"
// . "\t\t\tdocument.getElementById(controlid).src='".$imagefiles."/edithtmlpopup_disabled.png';\n"
. "\t\t\tdocument.getElementById(controlidena).style.display='none';\n"
. "\t\t\tdocument.getElementById(controliddis).style.display='';\n"
. "\t\t\tpopup = window.open('".$homeurl."/htmleditor-popup.php?fieldname='+fieldname+'&fieldtext='+fieldtext+'&fieldtype='+fieldtype+'&action='+action+'&sid='+sid+'&gid='+gid+'&qid='+qid+'&lang=".$clang->getlangcode()."','', 'location=no, status=yes, scrollbars=auto, menubar=no, resizable=yes, width=600, height=400');\n"
. "\t\t\teditorwindowsHash[fieldname] = popup;\n"
. "\t\t}\n"
. "\t\telse\n"
. "\t\t{\n"
. "\t\t\tactivepopup.focus();\n"
. "\t\t}\n"
. "\t}\n"
. "\n"
. "function updateFCKeditor(fieldname,value)\n"
. "{\t\n"
. "\tvar mypopup= editorwindowsHash[fieldname];\n"
. "\tif (mypopup)\n"
. "\t{\n"
. "\t\tvar oMyEditor = mypopup.FCKeditorAPI.GetInstance('MyTextarea');\n"
. "\t\tif (oMyEditor) {oMyEditor.SetHTML(value);}\n"
. "\t\tmypopup.focus();\n"
. "\t}\n"
. "}\n"
. "--></script>\n";
return $script;
}
function PrepareEditorInlineScript()
{
global $homeurl, $fckeditordir;
$script ="<script type=\"text/javascript\" src=\"".$fckeditordir."/fckeditor.js\"></script>\n"
. "<script type=\"text/javascript\">\n"
. "<!--\n"
. "function updateFCKeditor(fieldname,value)\n"
. "{\n"
. "\tvar oMyEditor = FCKeditorAPI.GetInstance(fieldname);\n"
. "\toMyEditor.SetHTML(value);\n"
. "}\n"
. "-->\n"
. "</script>\n";
/*** Commented because of inconsistencies
$script .= ""
. "<script type='text/javascript'>\n"
. "<!--\n"
."function FCKeditor_OnComplete( editorInstance )\n"
. "{\n"
. "\teditorInstance.Events.AttachEvent( 'OnBlur' , FCKeditor_OnBlur ) ;\n"
. "\teditorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;\n"
."}\n"
. "function FCKeditor_OnBlur( editorInstance )\n"
. "{\n"
. "\teditorInstance.ToolbarSet.Collapse() ;\n"
. "}\n"
. "function FCKeditor_OnFocus( editorInstance )\n"
. "{\n"
."\teditorInstance.ToolbarSet.Expand() ;\n"
."}\n"
. "--></script>\n";
***/
return $script;
}
function PrepareEditorScript($fieldtype=null)
{
global $defaulthtmleditormode;
if (isset($_SESSION['htmleditormode']) &&
$_SESSION['htmleditormode'] == 'none')
{
return "<script type=\"text/javascript\">\n"
. "<!--\n"
. "function updateFCKeditor(fieldname,value) { return true;}\n"
. "-->\n"
. "</script>\n";
}
if (!isset($_SESSION['htmleditormode']) ||
($_SESSION['htmleditormode'] != 'inline' &&
$_SESSION['htmleditormode'] != 'popup') )
{
$htmleditormode = $defaulthtmleditormode;
}
else
{
$htmleditormode = $_SESSION['htmleditormode'];
}
if ($htmleditormode == 'popup' ||
$fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
return PrepareEditorPopupScript();
}
elseif ($htmleditormode == 'inline')
{
return PrepareEditorInlineScript();
}
else
{
return '';
}
}
function getEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
global $defaulthtmleditormode;
if (isset($_SESSION['htmleditormode']) &&
$_SESSION['htmleditormode'] == 'none')
{
return '';
}
if (!isset($_SESSION['htmleditormode']) ||
($_SESSION['htmleditormode'] != 'inline' &&
$_SESSION['htmleditormode'] != 'popup') )
{
$htmleditormode = $defaulthtmleditormode;
}
else
{
$htmleditormode = $_SESSION['htmleditormode'];
}
if ( ($fieldtype == 'email-inv' ||
$fieldtype == 'email-reg' ||
$fieldtype == 'email-conf' ||
$fieldtype == 'email-rem' ) &&
getEmailFormat($surveyID) != 'html')
{
return '';
}
if ($htmleditormode == 'popup' ||
$fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
return getPopupEditor($fieldtype,$fieldname,$fieldtext, $surveyID,$gID,$qID,$action);
}
elseif ($htmleditormode == 'inline')
{
return getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID,$gID,$qID,$action);
}
else
{
return '';
}
}
function getPopupEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
global $clang, $imagefiles, $homeurl;
$htmlcode = '';
$imgopts = '';
$toolbarname = 'Basic';
if ($fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
$imgopts = "width='14' height='14'";
}
$htmlcode .= ""
. "<a href=\"javascript:start_popup_editor('".$fieldname."','".$fieldtext."','".$surveyID."','".$gID."','".$qID."','".$fieldtype."','".$action."')\" id='".$fieldname."_ctrl' title=\"".$clang->gTview("Start HTML Editor in a Popup Window")."\"><img alt=\"".$clang->gT("Start HTML Editor in a Popup Window")."\" id='".$fieldname."_popupctrlena' name='".$fieldname."_popupctrlena' border='0' src='".$imagefiles."/edithtmlpopup.png' $imgopts /><img alt=\"".$clang->gT("Give focus to the HTML Editor Popup Window")."\" id='".$fieldname."_popupctrldis' name='".$fieldname."_popupctrldis' border='0' src='".$imagefiles."/edithtmlpopup_disabled.png' style='display: none' $imgopts align='top'/></a>";
return $htmlcode;
}
function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null)
{
global $clang, $imagefiles, $homeurl, $rooturl, $fckeditordir, $fckeditexpandtoolbar;
$htmlcode = '';
$imgopts = '';
$toolbarname = 'Basic';
$toolbaroption="";
$htmlformatoption="";
$oFCKeditorVarName = "oFCKeditor_".str_replace("-","_",$fieldname);
if ($fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
$toolbarname = 'LimeSurveyToolbarfull';
$toolbaroption="$oFCKeditorVarName.Config[\"ToolbarLocation\"]=\"Out:xToolbar\";\n"
. "$oFCKeditorVarName.Config[\"ToolbarStartExpanded\"]=true;\n"
. "$oFCKeditorVarName.Config[\"ToolbarCanCollapse\"]=false;\n"
. "$oFCKeditorVarName.Height = \"50\"\n";
}
else
{
if (!isset($fckeditexpandtoolbar) || $fckeditexpandtoolbar == true)
{
$toolbaroption .= "$oFCKeditorVarName.Config[\"ToolbarStartExpanded\"]=true;\n";
}
}
if ( $fieldtype == 'email-inv' ||
$fieldtype == 'email-reg' ||
$fieldtype == 'email-conf' ||
$fieldtype == 'email-rem' )
{
$htmlformatoption = "$oFCKeditorVarName.Config[\"FullPage\"]=true;\n";
}
$htmlcode .= ""
. "<script type=\"text/javascript\">\n"
. "var $oFCKeditorVarName = new FCKeditor('$fieldname');\n"
. "$oFCKeditorVarName.BasePath = '".$fckeditordir."/';\n"
. "$oFCKeditorVarName.Config[\"CustomConfigurationsPath\"] = \"".$fckeditordir."/limesurvey-config.js\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsSID\"] = \"".$surveyID."\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsGID\"] = \"".$gID."\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsQID\"] = \"".$qID."\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";\n"
. "$oFCKeditorVarName.Config[\"LimeReplacementFieldsAction\"] = \"".$action."\";\n"
. "$oFCKeditorVarName.Config[\"SmileyPath\"] = \"".$rooturl."/upload/images/smiley/msn/\";\n"
. $htmlformatoption
. $toolbaroption;
if ($fieldtype == 'answer' || $fieldtype == 'label')
{
$htmlcode .= ""
. "$oFCKeditorVarName.Config[ 'ToolbarLocation' ] = 'Out:xToolbar' ;\n";
}
$htmlcode .= ""
. "$oFCKeditorVarName.ToolbarSet = '".$toolbarname."';\n"
. "$oFCKeditorVarName.ReplaceTextarea() ;\n"
. '</script>';
return $htmlcode;
}
?>

View File

@@ -1,197 +1,197 @@
<?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: htmleditor-popup.php 5074 2008-06-15 11:56:13Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
//include_once("login_check.php");
require_once(dirname(__FILE__).'/../config-defaults.php');
require_once(dirname(__FILE__).'/../common.php');
if (!isset($_GET['lang']))
{
$clang = new limesurvey_lang("en");
}
else
{
$clang = new limesurvey_lang($_GET['lang']);
}
if (!isset($_GET['fieldname']) || !isset($_GET['fieldtext']))
{
$output = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title>LimeSurvey '.$clang->gT("HTML Editor").'</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
</head>'
. '
<body>
<div class="maintitle">
LimeSurvey '.$clang->gT("HTML Editor").'
</div>
<hr />
<tr><td align="center"><br /><font color="red"><strong>
</strong></font><br />
</table>
<form onsubmit="self.close()">
<input type="submit" value="'.$clang->gT("Close Editor").'" />
<input type="hidden" name="checksessionbypost" value="'.$_SESSION['checksessionpost'].'" />
</form>
</body>
</html>';
}
else {
$fieldname=$_GET['fieldname'];
$fieldtext=$_GET['fieldtext'];
$controlidena=$_GET['fieldname'].'_popupctrlena';
$controliddis=$_GET['fieldname'].'_popupctrldis';
$sid=sanitize_int($_GET['sid']);
$gid=sanitize_int($_GET['gid']);
$qid=sanitize_int($_GET['qid']);
$fieldtype=preg_replace("/[^_.a-zA-Z0-9-]/", "",$_GET['fieldtype']);
$action=preg_replace("/[^_.a-zA-Z0-9-]/", "",$_GET['action']);
$toolbarname='LimeSurveyToolbarfullPopup';
$htmlformatoption='';
if ( $fieldtype == 'email-inv' ||
$fieldtype == 'email-reg' ||
$fieldtype == 'email-conf' ||
$fieldtype == 'email-rem' )
{
$htmlformatoption = "oFCKeditor.Config[\"FullPage\"]=true;";
}
$output = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title>'.$clang->gT("Editing").' '.$fieldtext.'</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="'.$fckeditordir.'/fckeditor.js"></script>
</head>';
$output .= "
<body>
<form method='post' onsubmit='saveChanges=true;'>
<input type='hidden' name='checksessionbypost' value='".$_SESSION['checksessionpost']."' />
<script type='text/javascript'>
<!--
function closeme()
{
window.onbeforeunload = new Function('return true;');
self.close();
}
window.onbeforeunload= function (evt) {
close_editor();
closeme();
}
var saveChanges = false;
var oFCKeditor = new FCKeditor( 'MyTextarea' );
oFCKeditor.BasePath = '".$fckeditordir."/';
oFCKeditor.Height = '350';
oFCKeditor.Width = '98%';
oFCKeditor.Value = window.opener.document.getElementsByName(\"".$fieldname."\")[0].value;
oFCKeditor.Config[\"CustomConfigurationsPath\"] = \"".$fckeditordir."/limesurvey-config.js\";
oFCKeditor.Config[\"ToolbarStartExpanded\"] = true;
oFCKeditor.Config[\"ToolbarCanCollapse\"] = false;
oFCKeditor.ToolbarSet = '".$toolbarname."';
oFCKeditor.Config[\"LimeReplacementFieldsSID\"] = \"".$sid."\";
oFCKeditor.Config[\"LimeReplacementFieldsGID\"] = \"".$gid."\";
oFCKeditor.Config[\"LimeReplacementFieldsQID\"] = \"".$qid."\";
oFCKeditor.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";
oFCKeditor.Config[\"LimeReplacementFieldsAction\"] = \"".$action."\";
oFCKeditor.Config[\"SmileyPath\"] = \"".$rooturl."/upload/images/smiley/msn/\";
$htmlformatoption
oFCKeditor.Create();
function FCKeditor_OnComplete( editorInstance )
{
//editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;
editorInstance.ToolbarSet.CurrentInstance.Commands.GetCommand('FitWindow').Execute();
window.status='LimeSurvey ".$clang->gT("Editing", "js")." ".javascript_escape($fieldtext,true)."';
}
function html_transfert()
{
var oEditor = FCKeditorAPI.GetInstance('MyTextarea');\n";
if ($fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
$output .= "\t\tvar editedtext = oEditor.GetXHTML().replace(new RegExp( \"\\n\", \"g\" ),'');\n";
$output .= "\t\tvar editedtext = oEditor.GetXHTML().replace(new RegExp( \"\\r\", \"g\" ),'');\n";
}
else
{
//$output .= "\t\tvar editedtext = oEditor.GetXHTML();\n";
$output .= "\t\tvar editedtext = oEditor.GetXHTML('no strip new line');\n"; // adding a parameter avoids stripping \n
}
$output .= "
window.opener.document.getElementsByName('".$fieldname."')[0].value = editedtext;
}
function close_editor()
{
if (saveChanges == false)
{
if (confirm('".$clang->gT("Do you want to save your changes ?", "js")."'))
{
html_transfert();
}
}
if (saveChanges == true)
{
html_transfert();
}
window.opener.document.getElementsByName('".$fieldname."')[0].readOnly= false;
window.opener.document.getElementsByName('".$fieldname."')[0].className='htmlinput';
window.opener.document.getElementById('".$controlidena."').style.display='';
window.opener.document.getElementById('".$controliddis."').style.display='none';
window.opener.focus();
return true;
}
//-->
</script>
</form>";
//$output .= "<textarea id='MyTextarea' name='MyTextarea'></textarea>";
$output .= "
</body>
</html>";
}
echo $output;
?>
<?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: htmleditor-popup.php 6853 2009-05-15 12:51:09Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
//include_once("login_check.php");
require_once(dirname(__FILE__).'/../config-defaults.php');
require_once(dirname(__FILE__).'/../common.php');
if (!isset($_GET['lang']))
{
$clang = new limesurvey_lang("en");
}
else
{
$clang = new limesurvey_lang($_GET['lang']);
}
if (!isset($_GET['fieldname']) || !isset($_GET['fieldtext']))
{
$output = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title>LimeSurvey '.$clang->gT("HTML Editor").'</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
</head>'
. '
<body>
<div class="maintitle">
LimeSurvey '.$clang->gT("HTML Editor").'
</div>
<hr />
<tr><td align="center"><br /><span style="color:red;"><strong>
</strong></span><br />
</table>
<form onsubmit="self.close()">
<input type="submit" value="'.$clang->gT("Close Editor").'" />
<input type="hidden" name="checksessionbypost" value="'.$_SESSION['checksessionpost'].'" />
</form>
</body>
</html>';
}
else {
$fieldname=$_GET['fieldname'];
$fieldtext=$_GET['fieldtext'];
$controlidena=$_GET['fieldname'].'_popupctrlena';
$controliddis=$_GET['fieldname'].'_popupctrldis';
$sid=sanitize_int($_GET['sid']);
$gid=sanitize_int($_GET['gid']);
$qid=sanitize_int($_GET['qid']);
$fieldtype=preg_replace("/[^_.a-zA-Z0-9-]/", "",$_GET['fieldtype']);
$action=preg_replace("/[^_.a-zA-Z0-9-]/", "",$_GET['action']);
$toolbarname='LimeSurveyToolbarfullPopup';
$htmlformatoption='';
if ( $fieldtype == 'email-inv' ||
$fieldtype == 'email-reg' ||
$fieldtype == 'email-conf' ||
$fieldtype == 'email-rem' )
{
$htmlformatoption = "oFCKeditor.Config[\"FullPage\"]=true;";
}
$output = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title>'.$clang->gT("Editing").' '.$fieldtext.'</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="'.$fckeditordir.'/fckeditor.js"></script>
</head>';
$output .= "
<body>
<form method='post' onsubmit='saveChanges=true;'>
<input type='hidden' name='checksessionbypost' value='".$_SESSION['checksessionpost']."' />
<script type='text/javascript'>
<!--
function closeme()
{
window.onbeforeunload = new Function('return true;');
self.close();
}
window.onbeforeunload= function (evt) {
close_editor();
closeme();
}
var saveChanges = false;
var oFCKeditor = new FCKeditor( 'MyTextarea' );
oFCKeditor.BasePath = '".$fckeditordir."/';
oFCKeditor.Height = '350';
oFCKeditor.Width = '98%';
oFCKeditor.Value = window.opener.document.getElementsByName(\"".$fieldname."\")[0].value;
oFCKeditor.Config[\"CustomConfigurationsPath\"] = \"".$fckeditordir."/limesurvey-config.js\";
oFCKeditor.Config[\"ToolbarStartExpanded\"] = true;
oFCKeditor.Config[\"ToolbarCanCollapse\"] = false;
oFCKeditor.ToolbarSet = '".$toolbarname."';
oFCKeditor.Config[\"LimeReplacementFieldsSID\"] = \"".$sid."\";
oFCKeditor.Config[\"LimeReplacementFieldsGID\"] = \"".$gid."\";
oFCKeditor.Config[\"LimeReplacementFieldsQID\"] = \"".$qid."\";
oFCKeditor.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";
oFCKeditor.Config[\"LimeReplacementFieldsAction\"] = \"".$action."\";
oFCKeditor.Config[\"SmileyPath\"] = \"".$rooturl."/upload/images/smiley/msn/\";
$htmlformatoption
oFCKeditor.Create();
function FCKeditor_OnComplete( editorInstance )
{
//editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;
editorInstance.ToolbarSet.CurrentInstance.Commands.GetCommand('FitWindow').Execute();
window.status='LimeSurvey ".$clang->gT("Editing", "js")." ".javascript_escape($fieldtext,true)."';
}
function html_transfert()
{
var oEditor = FCKeditorAPI.GetInstance('MyTextarea');\n";
if ($fieldtype == 'editanswer' ||
$fieldtype == 'addanswer' ||
$fieldtype == 'editlabel' ||
$fieldtype == 'addlabel')
{
$output .= "\t\tvar editedtext = oEditor.GetXHTML().replace(new RegExp( \"\\n\", \"g\" ),'');\n";
$output .= "\t\tvar editedtext = oEditor.GetXHTML().replace(new RegExp( \"\\r\", \"g\" ),'');\n";
}
else
{
//$output .= "\t\tvar editedtext = oEditor.GetXHTML();\n";
$output .= "\t\tvar editedtext = oEditor.GetXHTML('no strip new line');\n"; // adding a parameter avoids stripping \n
}
$output .= "
window.opener.document.getElementsByName('".$fieldname."')[0].value = editedtext;
}
function close_editor()
{
if (saveChanges == false)
{
if (confirm('".$clang->gT("Do you want to save your changes ?", "js")."'))
{
html_transfert();
}
}
if (saveChanges == true)
{
html_transfert();
}
window.opener.document.getElementsByName('".$fieldname."')[0].readOnly= false;
window.opener.document.getElementsByName('".$fieldname."')[0].className='htmlinput';
window.opener.document.getElementById('".$controlidena."').style.display='';
window.opener.document.getElementById('".$controliddis."').style.display='none';
window.opener.focus();
return true;
}
//-->
</script>
</form>";
//$output .= "<textarea id='MyTextarea' name='MyTextarea'></textarea>";
$output .= "
</body>
</html>";
}
echo $output;
?>

View File

@@ -1,47 +1,47 @@
<?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: http_importsurvey.php 4037 2008-01-20 15:23:53Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
// A FILE TO IMPORT A DUMPED SURVEY FILE, AND CREATE A NEW SURVEY
$importsurvey = "<br /><table width='100%' align='center'><tr><td>\n";
$importsurvey .= "<table class='alertbox'>\n";
$importsurvey .= "\t<tr ><td colspan='2' height='4'><font size='1' ><strong>"
.$clang->gT("Import Survey")."</strong></font></td></tr>\n";
$importsurvey .= "\t<tr ><td align='center'>\n";
$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path))
{
$importsurvey .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importsurvey .= sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$tempdir)."<br /><br />\n";
$importsurvey .= "</font></td></tr></table>\n";
return;
}
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
$importsurvey .= "<strong><font class='successtitle'>".$clang->gT("Success")."!</font></strong><br />\n";
$importsurvey .= $clang->gT("File upload succeeded.")."<br /><br />\n";
$importsurvey .= $clang->gT("Reading file..")."<br />\n";
$importingfrom = "http"; // "http" for the web version and "cmdline" for the command line version
include("importsurvey.php");
?>
<?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: http_importsurvey.php 6853 2009-05-15 12:51:09Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
// A FILE TO IMPORT A DUMPED SURVEY FILE, AND CREATE A NEW SURVEY
$importsurvey = "<br /><table width='100%' align='center'><tr><td>\n";
$importsurvey .= "<table class='alertbox'>\n";
$importsurvey .= "\t<tr ><td colspan='2' height='4'><font size='1' ><strong>"
.$clang->gT("Import Survey")."</strong></font></td></tr>\n";
$importsurvey .= "\t<tr ><td align='center'>\n";
$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path))
{
$importsurvey .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importsurvey .= sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$tempdir)."<br /><br />\n";
$importsurvey .= "</font></td></tr></table>\n";
return;
}
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
$importsurvey .= "<strong><font class='successtitle'>".$clang->gT("Success")."!</font></strong><br />\n";
$importsurvey .= $clang->gT("File upload succeeded.")."<br /><br />\n";
$importsurvey .= $clang->gT("Reading file..")."<br />\n";
$importingfrom = "http"; // "http" for the web version and "cmdline" for the command line version
include("importsurvey.php");
?>

View File

@@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: import_resources_zip.php 3685 2007-11-22 04:53:18Z jcleeland $
* $Id: import_resources_zip.php 6864 2009-05-17 22:33:37Z c_schmitz $
*/
@@ -26,7 +26,16 @@ if (!isset($lid))
returnglobal('lid');
}
if ($action == "importsurvresources" && $surveyid) {
if ($demoModeOnly === true)
{
$importsurvresourcesoutput = "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importsurvresourcesoutput .= $clang->gT("Demo Mode Only: Uploading file is disabled in this system.")."<br /><br />\n";
$importsurvresourcesoutput .= "<input type='submit' value='".$clang->gT("Back")."' onclick=\"window.open('$scriptname?action=editsurvey&amp;sid=$surveyid', '_self')\" />&nbsp;<br />&nbsp;<br />\n";
return;
}
require("classes/phpzip/phpzip.inc.php");
$zipfile=$_FILES['the_file']['tmp_name'];
$z = new PHPZip();
@@ -197,6 +206,15 @@ if ($action == "importsurvresources" && $surveyid) {
if ($action == "importlabelresources" && $lid)
{
if ($demoModeOnly === true)
{
$importlabelresourcesoutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importlabelresourcesoutput .= sprintf ($clang->gT("Demo Mode Only: Uploading file is disabled in this system."),$basedestdir)."<br /><br />\n";
$importlabelresourcesoutput .= "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname?action=labels&lid=$lid', '_self')\">\n";
$importlabelresourcesoutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
require("classes/phpzip/phpzip.inc.php");
//$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
$zipfile=$_FILES['the_file']['tmp_name'];
@@ -363,6 +381,187 @@ if ($action == "importlabelresources" && $lid)
if ($action == "templateupload")
{
if ($demoModeOnly === true)
{
$importtemplateresourcesoutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importtemplateoutput .= sprintf ($clang->gT("Demo mode: Uploading templates is disabled."),$basedestdir)."<br /><br />\n";
$importtemplateoutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
require("classes/phpzip/phpzip.inc.php");
//$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
$zipfile=$_FILES['the_file']['tmp_name'];
$z = new PHPZip();
// Create temporary directory
// If dangerous content is unzipped
// then no one will know the path
$extractdir=tempdir($tempdir);
$basedestdir = $templaterootdir;
$newdir=str_replace('.','',strip_ext(sanitize_paranoid_string($_FILES['the_file']['name'])));
$destdir=$basedestdir.'/'.$newdir.'/';
$importtemplateoutput = "<br />\n";
$importtemplateoutput .= "<table class='alertbox'>\n";
$importtemplateoutput .= "\t<tr><td colspan='2' height='4'><strong>".$clang->gT("Import Label Set")."</strong></td></tr>\n";
$importtemplateoutput .= "\t<tr><td align='center'>\n";
if (!is_writeable($basedestdir))
{
$importtemplateoutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importtemplateoutput .= sprintf ($clang->gT("Incorrect permissions in your %s folder."),$basedestdir)."<br /><br />\n";
$importtemplateoutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
if (!is_dir($destdir))
{
mkdir($destdir);
}
else
{
$importtemplateoutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importtemplateoutput .= sprintf ($clang->gT("Template '%s' does already exist."),$newdir)."<br /><br />\n";
$importtemplateoutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
$aImportedFilesInfo=array();
$aErrorFilesInfo=array();
if (is_file($zipfile))
{
$importtemplateoutput .= "<strong><font class='successtitle'>".$clang->gT("Success")."</font></strong><br />\n";
$importtemplateoutput .= $clang->gT("File upload succeeded.")."<br /><br />\n";
$importtemplateoutput .= $clang->gT("Reading file..")."<br />\n";
if ($z->extract($extractdir,$zipfile) != 'OK')
{
$importtemplateoutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importtemplateoutput .= $clang->gT("This file is not a valid ZIP file archive. Import failed.")."<br /><br />\n";
$importtemplateoutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
$ErrorListHeader = "";
$ImportListHeader = "";
// now read tempdir and copy authorized files only
$dh = opendir($extractdir);
while($direntry = readdir($dh))
{
if (($direntry!=".")&&($direntry!=".."))
{
if (is_file($extractdir."/".$direntry))
{ // is a file
$extfile = substr(strrchr($direntry, '.'),1);
if (!(stripos(','.$allowedresourcesuploads.',',','.$extfile.',') === false))
{ //Extension allowed
if (!copy($extractdir."/".$direntry, $destdir.$direntry))
{
$aErrorFilesInfo[]=Array(
"filename" => $direntry,
"status" => $clang->gT("Copy failed")
);
unlink($extractdir."/".$direntry);
}
else
{
$aImportedFilesInfo[]=Array(
"filename" => $direntry,
"status" => $clang->gT("OK")
);
unlink($extractdir."/".$direntry);
}
}
else
{ // Extension forbidden
$aErrorFilesInfo[]=Array(
"filename" => $direntry,
"status" => $clang->gT("Error")." (".$clang->gT("Forbidden Extension").")"
);
unlink($extractdir."/".$direntry);
}
} // end if is_file
} // end if ! . or ..
} // end while read dir
//Delete the temporary file
unlink($zipfile);
closedir($dh);
//Delete temporary folder
rmdir($extractdir);
// display summary
$okfiles = 0;
$errfiles= 0;
if (count($aErrorFilesInfo)==0 && count($aImportedFilesInfo)>0)
{
$status=$clang->gT("Success");
$color='green';
$okfiles = count($aImportedFilesInfo);
$ImportListHeader .= "<br /><strong><u>".$clang->gT("Imported Files List").":</u></strong><br />\n";
}
elseif (count($aErrorFilesInfo)==0 && count($aImportedFilesInfo)==0)
{
$importtemplateoutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importtemplateoutput .= $clang->gT("This ZIP archive contains no valid template files. Import failed.")."<br /><br />\n";
$importtemplateoutput .= $clang->gT("Remember that we do not support subdirectories in ZIP archives.")."<br /><br />\n";
$importtemplateoutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
elseif (count($aErrorFilesInfo)>0 && count($aImportedFilesInfo)>0)
{
$status=$clang->gT("Partial");
$color='orange';
$okfiles = count($aImportedFilesInfo);
$errfiles = count($aErrorFilesInfo);
$ErrorListHeader .= "<br /><strong><u>".$clang->gT("Error Files List").":</u></strong><br />\n";
$ImportListHeader .= "<br /><strong><u>".$clang->gT("Imported Files List").":</u></strong><br />\n";
}
else
{
$status=$clang->gT("Error");
$color='red';
$errfiles = count($aErrorFilesInfo);
$ErrorListHeader .= "<br /><strong><u>".$clang->gT("Error Files List").":</u></strong><br />\n";
}
$importtemplateoutput .= "<strong>".$clang->gT("Imported template files for")."</strong> $lid<br />\n";
$importtemplateoutput .= "<br />\n<strong><font color='$color'>".$status."</font></strong><br />\n";
$importtemplateoutput .= "<strong><u>".$clang->gT("Resources Import Summary")."</u></strong><br />\n";
$importtemplateoutput .= "".$clang->gT("Total Imported files").": $okfiles<br />\n";
$importtemplateoutput .= "".$clang->gT("Total Errors").": $errfiles<br />\n";
$importtemplateoutput .= $ImportListHeader;
foreach ($aImportedFilesInfo as $entry)
{
$importtemplateoutput .= "\t<li>".$clang->gT("File").": ".$entry["filename"]."</li>\n";
}
$importtemplateoutput .= "\t</ul><br /><br />\n";
$importtemplateoutput .= $ErrorListHeader;
foreach ($aErrorFilesInfo as $entry)
{
$importtemplateoutput .= "\t<li>".$clang->gT("File").": ".$entry['filename']." (".$entry['status'].")</li>\n";
}
}
else
{
$importtemplateoutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importtemplateoutput .= sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$basedestdir)."<br /><br />\n";
$importtemplateoutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
$importtemplateoutput .= "<input type='submit' value='".$clang->gT("Open imported template")."' onclick=\"window.open('$scriptname?action=templates&templatename=$newdir', '_self')\">\n";
}
//---------------------
// Comes from http://fr2.php.net/tempnam
function tempdir($dir, $prefix='', $mode=0700)
@@ -377,4 +576,20 @@ if ($action == "importlabelresources" && $lid)
return $path;
}
/**
* Strips file extension
*
* @param string $name
* @return string
*/
function strip_ext($name)
{
$ext = strrchr($name, '.');
if($ext !== false)
{
$name = substr($name, 0, -strlen($ext));
}
return $name;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,219 +1,223 @@
<?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: importlabel.php 4973 2008-06-01 14:07:01Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
// A FILE TO IMPORT A DUMPED SURVEY FILE, AND CREATE A NEW SURVEY
$importlabeloutput = "<br />\n";
$importlabeloutput .= "<table class='alertbox'>\n";
$importlabeloutput .= "\t<tr><td colspan='2' height='4'><strong>".$clang->gT("Import Label Set")."</strong></td></tr>\n";
$importlabeloutput .= "\t<tr><td align='center'>\n";
$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path))
{
$importlabeloutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importlabeloutput .= sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$tempdir)."<br /><br />\n";
$importlabeloutput .= "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
$importlabeloutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
$csarray=buildLabelSetCheckSumArray();
//$csarray is now a keyed array with the Checksum of each of the label sets, and the lid as the key
$importlabeloutput .= "<strong><font class='successtitle'>".$clang->gT("Success")."</font></strong><br />\n";
$importlabeloutput .= $clang->gT("File upload succeeded.")."<br /><br />\n";
$importlabeloutput .= $clang->gT("Reading file..")."<br />\n";
$handle = fopen($the_full_file_path, "r");
while (!feof($handle))
{
$buffer = fgets($handle, 10240); //To allow for very long survey welcomes (up to 10k)
$bigarray[] = $buffer;
}
fclose($handle);
if (substr($bigarray[0], 0, 27) != "# LimeSurvey Label Set Dump" && substr($bigarray[0], 0, 28) != "# PHPSurveyor Label Set Dump")
{
$importlabeloutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importlabeloutput .= $clang->gT("This file is not a LimeSurvey label set file. Import failed.")."<br /><br />\n";
$importlabeloutput .= "<input type='submit' value='".$clang->gT("Return to Labels Admin")."' onclick=\"window.open('$scriptname?action=labels', '_self')\">\n";
$importlabeloutput .= "</td></tr></table>\n";
$importlabeloutput .= "</body>\n</html>\n";
unlink($the_full_file_path);
return;
}
for ($i=0; $i<9; $i++) //skipping the first lines that are not needed
{
unset($bigarray[$i]);
}
$bigarray = array_values($bigarray);
//LABEL SETS
if (array_search("# LABELS TABLE\n", $bigarray))
{
$stoppoint = array_search("# LABELS TABLE\n", $bigarray);
}
elseif (array_search("# LABELS TABLE\r\n", $bigarray))
{
$stoppoint = array_search("# LABELS TABLE\r\n", $bigarray);
}
else
{
$stoppoint = count($bigarray)-1;
}
for ($i=0; $i<=$stoppoint+1; $i++)
{
if ($i<$stoppoint-2) {$labelsetsarray[] = $bigarray[$i];}
unset($bigarray[$i]);
}
$bigarray = array_values($bigarray);
//LABELS
$stoppoint = count($bigarray)-1;
for ($i=0; $i<$stoppoint; $i++)
{
// do not import empty lines
if (trim($bigarray[$i])!='')
{
$labelsarray[] = $bigarray[$i];
}
unset($bigarray[$i]);
}
$countlabelsets = count($labelsetsarray)-1;
$countlabels = count($labelsarray)-1;
if (isset($labelsetsarray) && $labelsetsarray) {
$csarray=buildLabelSetCheckSumArray(); // build checksums over all existing labelsets
$count=0;
foreach ($labelsetsarray as $lsa) {
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
$fieldcontents=convertCSVRowToArray($lsa,',','"');
if ($count==0) {$count++; continue;}
$labelsetrowdata=array_combine($fieldorders,$fieldcontents);
// Save old labelid
$oldlid=$labelsetrowdata['lid'];
// set the new language
unset($labelsetrowdata['lid']);
$countlang=count(explode(' ',trim($labelsetrowdata['languages'])));
$newvalues=array_values($labelsetrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lsainsert = "insert INTO {$dbprefix}labelsets (".implode(',',array_keys($labelsetrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$lsiresult=$connect->Execute($lsainsert);
// Get the new insert id for the labels inside this labelset
$newlid=$connect->Insert_ID("{$dbprefix}labelsets",'lid');
if ($labelsarray) {
$count=0;
$lfieldorders =convertCSVRowToArray($labelsarray[0],',','"');
unset($labelsarray[0]);
foreach ($labelsarray as $la) {
$lfieldcontents=convertCSVRowToArray($la,',','"');
// Combine into one array with keys and values since its easier to handle
$labelrowdata=array_combine($lfieldorders,$lfieldcontents);
$labellid=$labelrowdata['lid'];
if ($labellid == $oldlid) {
$labelrowdata['lid']=$newlid;
// translate internal links
$labelrowdata['title']=translink('label', $oldlid, $newlid, $labelrowdata['title']);
$newvalues=array_values($labelrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lainsert = "insert INTO {$dbprefix}labels (".implode(',',array_keys($labelrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$liresult=$connect->Execute($lainsert);
}
}
}
//CHECK FOR DUPLICATE LABELSETS
$thisset="";
$query2 = "SELECT code, title, sortorder, language
FROM ".db_table_name('labels')."
WHERE lid=".$newlid."
ORDER BY sortorder, code";
$result2 = db_execute_num($query2) or safe_die("Died querying labelset $lid<br />$query2<br />".$connect->ErrorMsg());
while($row2=$result2->FetchRow())
{
$thisset .= implode('.', $row2);
} // while
$newcs=dechex(crc32($thisset)*1);
unset($lsmatch);
if (isset($csarray))
{
foreach($csarray as $key=>$val)
{
// echo $val."-".$newcs."<br/>"; For debug purposes
if ($val == $newcs)
{
$lsmatch=$key;
}
}
}
if (isset($lsmatch))
{
//There is a matching labelset. So, we will delete this one and refer
//to the matched one.
$query = "DELETE FROM {$dbprefix}labels WHERE lid=$newlid";
$result=$connect->Execute($query) or safe_die("Couldn't delete labels<br />$query<br />".$connect->ErrorMsg());
$query = "DELETE FROM {$dbprefix}labelsets WHERE lid=$newlid";
$result=$connect->Execute($query) or safe_die("Couldn't delete labelset<br />$query<br />".$connect->ErrorMsg());
$newlid=$lsmatch;
$importlabeloutput.="<p><i><font color='red'>".$clang->gT("There was a duplicate labelset, so this set was not imported. The duplicate will be used instead.")."</font></i>\n";
$importlabeloutput .= "<strong>Existing LID:</strong> $newlid</p><br />\n";
}
else
{
$importlabeloutput .= "<strong>LID:</strong> $newlid<br />\n";
$importlabeloutput .= "<br />\n<strong><font class='successtitle'>".$clang->gT("Success")."</font></strong><br />\n";
$importlabeloutput .= "<strong><u>".$clang->gT("Label Set Import Summary")."</u></strong><br />\n";
$importlabeloutput .= "\t<li>".$clang->gT("Label Sets").": $countlabelsets</li>\n";
$importlabeloutput .= "\t<li>".$clang->gT("Labels").": $countlabels</li>\n";
$importlabeloutput .= "\t<li>".$clang->gT("Languages").": $countlang</li></ul><br />\n";
}
//END CHECK FOR DUPLICATES
}
}
$importlabeloutput .= "<strong>".$clang->gT("Import of Label Set is completed.")."</strong><br />\n";
$importlabeloutput .= "<input type='submit' value='".$clang->gT("Return to Labels Admin")."' onclick=\"window.open('$scriptname?action=labels&amp;lid=$newlid', '_self')\">\n";
$importlabeloutput .= "</td></tr></table>\n";
unlink($the_full_file_path);
?>
<?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: importlabel.php 7382 2009-08-01 19:48:15Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
// A FILE TO IMPORT A DUMPED SURVEY FILE, AND CREATE A NEW SURVEY
$importlabeloutput = "<br />\n";
$importlabeloutput .= "<table class='alertbox'>\n";
$importlabeloutput .= "\t<tr><td colspan='2' height='4'><strong>".$clang->gT("Import Label Set")."</strong></td></tr>\n";
$importlabeloutput .= "\t<tr><td align='center'>\n";
$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path))
{
$importlabeloutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importlabeloutput .= sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$tempdir)."<br /><br />\n";
$importlabeloutput .= "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_self')\">\n";
$importlabeloutput .= "</td></tr></table><br />&nbsp;\n";
return;
}
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
$csarray=buildLabelSetCheckSumArray();
//$csarray is now a keyed array with the Checksum of each of the label sets, and the lid as the key
$importlabeloutput .= "<strong><font class='successtitle'>".$clang->gT("Success")."</font></strong><br />\n";
$importlabeloutput .= $clang->gT("File upload succeeded.")."<br /><br />\n";
$importlabeloutput .= $clang->gT("Reading file..")."<br />\n";
$handle = fopen($the_full_file_path, "r");
while (!feof($handle))
{
$buffer = fgets($handle, 10240); //To allow for very long survey welcomes (up to 10k)
$bigarray[] = $buffer;
}
fclose($handle);
if (substr($bigarray[0], 0, 27) != "# LimeSurvey Label Set Dump" && substr($bigarray[0], 0, 28) != "# PHPSurveyor Label Set Dump")
{
$importlabeloutput .= "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
$importlabeloutput .= $clang->gT("This file is not a LimeSurvey label set file. Import failed.")."<br /><br />\n";
$importlabeloutput .= "<input type='submit' value='".$clang->gT("Return to Labels Admin")."' onclick=\"window.open('$scriptname?action=labels', '_self')\">\n";
$importlabeloutput .= "</td></tr></table>\n";
$importlabeloutput .= "</body>\n</html>\n";
unlink($the_full_file_path);
return;
}
for ($i=0; $i<9; $i++) //skipping the first lines that are not needed
{
unset($bigarray[$i]);
}
$bigarray = array_values($bigarray);
//LABEL SETS
if (array_search("# LABELS TABLE\n", $bigarray))
{
$stoppoint = array_search("# LABELS TABLE\n", $bigarray);
}
elseif (array_search("# LABELS TABLE\r\n", $bigarray))
{
$stoppoint = array_search("# LABELS TABLE\r\n", $bigarray);
}
else
{
$stoppoint = count($bigarray)-1;
}
for ($i=0; $i<=$stoppoint+1; $i++)
{
if ($i<$stoppoint-2) {$labelsetsarray[] = $bigarray[$i];}
unset($bigarray[$i]);
}
$bigarray = array_values($bigarray);
//LABELS
$stoppoint = count($bigarray)-1;
for ($i=0; $i<$stoppoint; $i++)
{
// do not import empty lines
if (trim($bigarray[$i])!='')
{
$labelsarray[] = $bigarray[$i];
}
unset($bigarray[$i]);
}
$countlabelsets = count($labelsetsarray)-1;
$countlabels = count($labelsarray)-1;
if (isset($labelsetsarray) && $labelsetsarray) {
$csarray=buildLabelSetCheckSumArray(); // build checksums over all existing labelsets
$count=0;
foreach ($labelsetsarray as $lsa) {
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
$fieldcontents=convertCSVRowToArray($lsa,',','"');
if ($count==0) {$count++; continue;}
$labelsetrowdata=array_combine($fieldorders,$fieldcontents);
// Save old labelid
$oldlid=$labelsetrowdata['lid'];
// set the new language
unset($labelsetrowdata['lid']);
$countlang=count(explode(' ',trim($labelsetrowdata['languages'])));
$newvalues=array_values($labelsetrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lsainsert = "insert INTO {$dbprefix}labelsets (".implode(',',array_keys($labelsetrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$lsiresult=$connect->Execute($lsainsert);
// Get the new insert id for the labels inside this labelset
$newlid=$connect->Insert_ID("{$dbprefix}labelsets",'lid');
if ($labelsarray) {
$count=0;
$lfieldorders =convertCSVRowToArray($labelsarray[0],',','"');
unset($labelsarray[0]);
foreach ($labelsarray as $la) {
$lfieldcontents=convertCSVRowToArray($la,',','"');
// Combine into one array with keys and values since its easier to handle
$labelrowdata=array_combine($lfieldorders,$lfieldcontents);
$labellid=$labelrowdata['lid'];
if ($labellid == $oldlid) {
$labelrowdata['lid']=$newlid;
// translate internal links
$labelrowdata['title']=translink('label', $oldlid, $newlid, $labelrowdata['title']);
if (!isset($labelrowdata["assessment_value"]))
{
$labelrowdata["assessment_value"]=(int)$labelrowdata["code"];
}
$newvalues=array_values($labelrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lainsert = "insert INTO {$dbprefix}labels (".implode(',',array_keys($labelrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$liresult=$connect->Execute($lainsert);
}
}
}
//CHECK FOR DUPLICATE LABELSETS
$thisset="";
$query2 = "SELECT code, title, sortorder, language, assessment_value
FROM ".db_table_name('labels')."
WHERE lid=".$newlid."
ORDER BY sortorder, code";
$result2 = db_execute_num($query2) or safe_die("Died querying labelset $lid<br />$query2<br />".$connect->ErrorMsg());
while($row2=$result2->FetchRow())
{
$thisset .= implode('.', $row2);
} // while
$newcs=dechex(crc32($thisset)*1);
unset($lsmatch);
if (isset($csarray))
{
foreach($csarray as $key=>$val)
{
// echo $val."-".$newcs."<br/>"; For debug purposes
if ($val == $newcs)
{
$lsmatch=$key;
}
}
}
if (isset($lsmatch))
{
//There is a matching labelset. So, we will delete this one and refer
//to the matched one.
$query = "DELETE FROM {$dbprefix}labels WHERE lid=$newlid";
$result=$connect->Execute($query) or safe_die("Couldn't delete labels<br />$query<br />".$connect->ErrorMsg());
$query = "DELETE FROM {$dbprefix}labelsets WHERE lid=$newlid";
$result=$connect->Execute($query) or safe_die("Couldn't delete labelset<br />$query<br />".$connect->ErrorMsg());
$newlid=$lsmatch;
$importlabeloutput.="<p><i><font color='red'>".$clang->gT("There was a duplicate labelset, so this set was not imported. The duplicate will be used instead.")."</font></i>\n";
$importlabeloutput .= "<strong>Existing LID:</strong> $newlid</p><br />\n";
}
else
{
$importlabeloutput .= "<strong>LID:</strong> $newlid<br />\n";
$importlabeloutput .= "<br />\n<strong><font class='successtitle'>".$clang->gT("Success")."</font></strong><br />\n";
$importlabeloutput .= "<strong><u>".$clang->gT("Label Set Import Summary")."</u></strong><br />\n";
$importlabeloutput .= "\t<li>".$clang->gT("Label Sets").": $countlabelsets</li>\n";
$importlabeloutput .= "\t<li>".$clang->gT("Labels").": $countlabels</li>\n";
$importlabeloutput .= "\t<li>".$clang->gT("Languages").": $countlang</li></ul><br />\n";
}
//END CHECK FOR DUPLICATES
}
}
$importlabeloutput .= "<strong>".$clang->gT("Import of Label Set is completed.")."</strong><br />\n";
$importlabeloutput .= "<input type='submit' value='".$clang->gT("Return to Labels Admin")."' onclick=\"window.open('$scriptname?action=labels&amp;lid=$newlid', '_self')\">\n";
$importlabeloutput .= "</td></tr></table>\n";
unlink($the_full_file_path);
?>

View File

@@ -1,138 +1,269 @@
<?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: importoldresponses.php 4973 2008-06-01 14:07:01Z c_schmitz $
*/
//import responses from an old_ survey table into an active survey
include_once("login_check.php");
if (!isset($oldtable)) {$oldtable=returnglobal('oldtable');}
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!$subaction == "import")
{
// show UI for choosing old table
$query = db_select_tables_like("{$dbprefix}old\_survey_{$surveyid}\_%");
$result = db_execute_num($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
$optionElements = '';
while ($row = $result->FetchRow())
{
$optionElements .= "\t\t\t<option>{$row[0]}</option>\n";
}
$importoldresponsesoutput = "";
$importoldresponsesoutput .= "<table width='99%' align='center' class='menubar' cellpadding='1' cellspacing='0'>\n"
."\t<tr><td colspan='2' height='4'><strong>".$clang->gT("Quick Statistics")."</strong></td></tr>\n";
//Get the menubar
$importoldresponsesoutput .= browsemenubar();
$importoldresponsesoutput .= "</table>\n";
$importoldresponsesoutput .= "<br /><table align='center' class='outlinetable'>
<tr>
<th colspan='2'>".$clang->gT("Import responses from an old (deactivated) survey table into an active survey")."</th>
</tr>
<form method='post'>
<tr>
<td align='right'>".$clang->gT("Target Survey ID")."</td>
<td> $surveyid<input type='hidden' value='$surveyid' name='sid'></td>
</tr>
<tr>
<td align='right'>
".$clang->gT("Source table").":
</td>
<td>
<select name='oldtable' >
{$optionElements}
</select>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<input type='submit' value='".$clang->gT("Import Responses")."' onclick='return confirm(\"".$clang->gT("Are you sure?","js").")'>&nbsp;
<input type='hidden' name='subaction' value='import'>
</td>
</tr>
</form>
</table><br />&nbsp;";
}
elseif (isset($surveyid) && $surveyid && isset($oldtable))
{
// options (UI not implemented)
$dontimportfields = array(
'id' //,'otherfield'
);
$presetfields = array( // quote all strings so we can allow NULL
//'4X13X951'=>"'Y'"
//'id' => "NULL"
);
$importidrange = false; //array('first'=>3,'last'=>10);
$activetable = "{$dbprefix}survey_$surveyid";
// fields we can import
$importablefields = array();
$query = "SHOW COLUMNS FROM {$activetable}";
$result = db_execute_assoc($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
while ($row = $result->FetchRow())
{
if (!in_array($row['Field'],$dontimportfields))
{
$importablefields[] = $row['Field'];
}
}
// fields we can supply
$availablefields = array();
$query = "SHOW COLUMNS FROM {$oldtable}";
$result = db_execute_assoc($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
while ($row = $result->FetchRow())
{
$availablefields[] = $row['Field'];
}
foreach ($presetfields as $field => $value)
{
if (!in_array($field,$availablefields))
{
$availablefields[] = $field;
}
}
$fieldstoimport = array_intersect($importablefields,$availablefields);
// data sources for each field (field of oldtable or preset value)
$sourcefields = array();
foreach ($fieldstoimport as $field)
{
$sourcefields[] = array_key_exists($field,$presetfields)?
$presetfields[$field]
: ($oldtable.'.'.$field);
}
$query = "INSERT INTO {$activetable} (\n\t".join("\t, ",$fieldstoimport)."\n) "
."SELECT\n\t".join("\t,",$sourcefields)."\n"
."FROM {$oldtable}";
if (is_array($importidrange))
{
$query .= " WHERE {$oldtable}.id >= {$importidrange['first']} "
." AND {$oldtable}.id <= {$importidrange['last']}";
}
$result = $connect->Execute($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
header("Location: $scriptname?action=browse&sid=$surveyid");
}
?>
<?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: importoldresponses.php 7058 2009-06-10 14:42:27Z c_schmitz $
*/
//import responses from an old_ survey table into an active survey
include_once("login_check.php");
if (!isset($oldtable)) {$oldtable=returnglobal('oldtable');}
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!$subaction == "import")
{
// show UI for choosing old table
$query = db_select_tables_like("{$dbprefix}old\_survey\_%");
$result = db_execute_num($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
$optionElements = '';
$queryCheckColumnsActive = "SELECT * FROM {$dbprefix}survey_{$surveyid} ";
$resultActive = db_execute_num($queryCheckColumnsActive) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
$countActive = $resultActive->FieldCount();
while ($row = $result->FetchRow())
{
$queryCheckColumnsOld = "SELECT * FROM {$row[0]} ";
$resultOld = db_execute_num($queryCheckColumnsOld) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
if($countActive== $resultOld->FieldCount())
{
$optionElements .= "\t\t\t<option value='{$row[0]}'>{$row[0]}</option>\n";
}
}
//Get the menubar
$importoldresponsesoutput = browsemenubar($clang->gT("Quick Statistics"));
$importoldresponsesoutput .= "<br />
<div class='header'>
".$clang->gT("Import responses from an deactivated survey table")."
</div>
<form id='personalsettings' method='post'>
<ul>
<li><label for='spansurveyid'>".$clang->gT("Target survey ID:")."</label>
<span id='spansurveyid'> $surveyid<input type='hidden' value='$surveyid' name='sid'></span>
</li>
<li>
<label for='oldtable'>
".$clang->gT("Source table:")."
</label>
<select name='oldtable' >
{$optionElements}
</select>
</li>
</ul>
<input type='submit' value='".$clang->gT("Import Responses")."' onclick='return confirm(\"".$clang->gT("Are you sure?","js").")'>&nbsp;
<input type='hidden' name='subaction' value='import'><br /><br />
<div class='warningtitle'>".$clang->gT("Warning: You can import all old responses with the same amount of columns as in your active survey. YOU have to make sure, that this responses corresponds to the questions in your active survey.")."</div>
</form>
</div>
<br />";
}
elseif (isset($surveyid) && $surveyid && isset($oldtable))
{
/*
* TODO:
* - mysql fit machen
* -- quotes für mysql beachten --> `
* - warnmeldung mehrsprachig
* - testen
*/
// if($databasetype=="postgres")
// {
$activetable = "{$dbprefix}survey_$surveyid";
//Fields we don't want to import
$dontimportfields = array(
'id' //,'otherfield'
);
// fields we can import
$importablefields = array();
if($databasetype=="postgres")
{
$query = "SELECT column_name as field FROM information_schema.columns WHERE table_name = '{$activetable}' ";
}
else
{
$query = "SHOW COLUMNS FROM {$activetable}";
}
$result = db_execute_assoc($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
while ($row = $result->FetchRow())
{
if($databasetype=="postgres")
{
if (!in_array($row['field'],$dontimportfields))
{
$importablefields[] = $row['field'];
}
}
else
{
if (!in_array($row['Field'],$dontimportfields))
{
$importablefields[] = $row['Field'];
}
}
}
foreach ($importablefields as $field => $value)
{
$fields2insert[]=($databasetype=="postgres") ? "\"".$value."\"" : "`".$value."`";
// if($databasetype=="postgres") { $fields2insert[] = "\"".$value."\""; }
}
//fields we can supply //fields in the old database
$availablefields = array();
if($databasetype=="postgres")
{
$query = "SELECT column_name as field FROM information_schema.columns WHERE table_name = '{$oldtable}' ";
}
else
{
$query = "SHOW COLUMNS FROM {$oldtable}";
}
$result = db_execute_assoc($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
while ($row = $result->FetchRow())
{
if($databasetype=="postgres")
{
if (!in_array($row['field'],$dontimportfields))
{
$availablefields[] = $row['field'];
}
}
else
{
if (!in_array($row['Field'],$dontimportfields))
{
$availablefields[] = $row['Field'];
}
}
}
foreach ($availablefields as $field => $value)
{
if($databasetype=="postgres")
{
$fields2import[] = "\"".$value."\"";
}
else
{
$fields2import[] = '`'.$value.'`';
}
}
$queryOldValues = "SELECT ".implode(", ",$fields2import)." "
. "FROM {$oldtable} ";
$resultOldValues = db_execute_assoc($queryOldValues) or safe_die("Error:<br />$queryOldValues<br />".$connect->ErrorMsg());
while ($row = $resultOldValues->FetchRow())
{
$values2import = array();
foreach($row as $fieldName => $fieldValue)
{
if( $fieldValue=="")
{
$values2import[] = "NULL";
}
else
{
if(!is_numeric($fieldValue))
$values2import[] = "'".db_quote($fieldValue)."'";
else
$values2import[] = "".$fieldValue."";
}
}
$insertOldValues = "INSERT INTO {$activetable} ( ".implode(", ",$fields2insert).") "
. "VALUES( ".implode(", ",$values2import)."); ";
$result = $connect->Execute($insertOldValues) or safe_die("Error:<br />$insertOldValues<br />".$connect->ErrorMsg());
}
// }
// else
// {
// // options (UI not implemented)
//
// $dontimportfields = array(
// 'id' //,'otherfield'
// );
// $presetfields = array( // quote all strings so we can allow NULL
// //'4X13X951'=>"'Y'"
// //'id' => "NULL"
// );
// $importidrange = false; //array('first'=>3,'last'=>10);
//
// $activetable = "{$dbprefix}survey_$surveyid";
//
// // fields we can import
// $importablefields = array();
// $query = "SHOW COLUMNS FROM {$activetable}";
// $result = db_execute_assoc($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
// while ($row = $result->FetchRow())
// {
// if (!in_array($row['Field'],$dontimportfields))
// {
// $importablefields[] = $row['Field'];
// }
// }
//
// // fields we can supply
// $availablefields = array();
// $query = "SHOW COLUMNS FROM {$oldtable}";
// $result = db_execute_assoc($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
// while ($row = $result->FetchRow())
// {
// $availablefields[] = $row['Field'];
// }
// foreach ($presetfields as $field => $value)
// {
// if (!in_array($field,$availablefields))
// {
// $availablefields[] = $field;
// }
// }
//
// $fieldstoimport = array_intersect($importablefields,$availablefields);
//
// // data sources for each field (field of oldtable or preset value)
// $sourcefields = array();
// foreach ($fieldstoimport as $field)
// {
// $sourcefields[] = array_key_exists($field,$presetfields)?
// $presetfields[$field]
// : ($oldtable.'.`'.$field.'`');
// $fieldstoimport2[] = '`'.$field.'`';
// }
//
// $query = "INSERT INTO {$activetable} (\n\t".join("\t, ",$fieldstoimport2)."\n) "
// ."SELECT\n\t".join("\t,",$sourcefields)."\n"
// ."FROM {$oldtable}";
// if (is_array($importidrange))
// {
// $query .= " WHERE {$oldtable}.id >= {$importidrange['first']} "
// ." AND {$oldtable}.id <= {$importidrange['last']}";
// }
//
// $result = $connect->Execute($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg());
// }
header("Location: $scriptname?action=browse&sid=$surveyid");
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=admin.php">
</head>
<body>
</body>
</html>
<html>
<head>
<meta http-equiv="refresh" content="0; URL=admin.php">
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,185 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Nicolas Barcet
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, 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: index.php 4729 2008-05-31 21:32:02Z nijaba $
*/
$cmd_install=true;
if (isset($argv[1]) && ($argv[1]=='install'|| $argv[1]=='upgrade') && isset($argv[2]) && isset($argv[3]))
{
require_once($argv[2]);
require_once($argv[3]);
}
else
{
require_once(dirname(__FILE__).'/../../config-defaults.php');
require_once(dirname(__FILE__).'/../../common.php');
}
// SET THE LANGUAGE???? -> DEFAULT SET TO EN FOR NOW
require_once($rootdir.'/classes/core/language.php');
$clang = new limesurvey_lang("en");
ob_implicit_flush(true);
if (isset($argv[1]) && $argv[1]=='install')
{
print("trying to create and populate $databasename on $databaselocation:$databaseport ($databasetype) \n");
if (!$database_exists) //Database named in config.php does not exist
{
if($connect->Execute("CREATE DATABASE $databasename;"))
{
print("\nDatabase $databasename on $databasetype CREATED \n");
}
else
{
print("\nDatabase $databasename on $databasetype COULD NOT BE CREATED \n");
print("\n".$connect->ErrorMsg());
return 1;
}
}
else
{
if ($databasetype=='mysql' || $databasetype=='mysqli') {$connect->Execute("ALTER DATABASE `$databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");} //Set the collation also for manually created DBs
print("\nDatabase $databasename on $databasetype EXISTS, not created \n");
}
// Connect to the database we created a sec ago or to the existing db.
if(!$connect->Connect($databaselocation,$databaseuser,$databasepass,$databasename))
{
print("\n".$connect->ErrorMsg());
return 1;
}
require_once($homedir."/classes/core/sha256.php");
$success = 0; // Let's be optimistic
$createdbtype=$databasetype;
if ($createdbtype=='mssql_n' || $createdbtype=='odbc_mssql' || $createdbtype=='odbtp') $createdbtype='mssql';
$sqlfile = dirname(__FILE__).'/create-'.$createdbtype.'.sql' ;
if (!empty($sqlfile)) {
if (!is_readable($sqlfile)) {
$success = false;
print "\nTried to populate database, but '". $sqlfile ."' doesn't exist!\n";
return $success;
} else {
$lines = file($sqlfile);
}
} else {
$sqlstring = trim($sqlstring);
if ($sqlstring{strlen($sqlstring)-1} != ";") {
$sqlstring .= ";"; // add it in if it's not there.
}
$lines[] = $sqlstring;
}
$command = '';
$connect->SetFetchMode(ADODB_FETCH_NUM);
foreach ($lines as $line) {
$line = rtrim($line);
$length = strlen($line);
if ($length and $line[0] <> '#' and substr($line,0,2) <> '--') {
if (substr($line, $length-1, 1) == ';') {
$line = substr($line, 0, $length-1); // strip ;
$command .= $line;
$command = str_replace('prefix_', $dbprefix, $command); // Table prefixes
$command = str_replace('$defaultuser', $defaultuser, $command); // variables By Moses
$command = str_replace('$defaultpass', SHA256::hashing($defaultpass), $command); // variables By Moses
$command = str_replace('$siteadminname', $siteadminname, $command);
$command = str_replace('$siteadminemail', $siteadminemail, $command); // variables By Moses
$command = str_replace('$defaultlang', $defaultlang, $command); // variables By Moses
$command = str_replace('$sessionname', 'ls'.getRandomID().getRandomID().getRandomID().getRandomID(), $command); // variables By Moses
$command = str_replace('$databasetabletype', $databasetabletype, $command);
if(!$connect->Execute($command,false))
{
print ("\n".$clang->gT("Executing").".....".$command."...".$clang->gT('Failed! Reason:')."\n".$connect->ErrorMsg()."\n\n");
$success=1;
}
$command = '';
} else {
$command .= $line;
}
}
}
$connect->SetFetchMode(ADODB_FETCH_ASSOC);
if($success == 0)
{
print("Database $databasename on $databasetype POPULATED");
print("\n\neverything went fine");
return $success;
}
else
{
print("\n\nSomething is strange");
print("\nplease check you Database and Settings");
return $success;
}
// if (modify_database(dirname(__FILE__).'\create-'.$databasetype.'.sql'))
// {
// print("\nDatabase $databasename on $databasetype POPULATED \n");
// return 0;
// } else {
// print("Could not populate $databasename on $databasetype\n");
// return 1;
// }
}
elseif (isset($argv[1]) && $argv[1]=='upgrade')
{
$upgradedbtype=$databasetype;
if ($upgradedbtype=='mssql_n' || $upgradedbtype=='odbc_mssql' || $upgradedbtype=='odbtp') $upgradedbtype='mssql';
include ('upgrade-'.$upgradedbtype.'.php');
$tables = $connect->MetaTables();
$usquery = "SELECT stg_value FROM ".db_table_name("settings_global")." where stg_name='DBVersion'";
$usresult = db_execute_assoc($usquery);
$usrow = $usresult->FetchRow();
if (intval($usrow['stg_value'])<$dbversionnumber)
{
print("Upgrading db to $dbversionnumber\n");
db_upgrade(intval($usrow['stg_value']));
} else {
print("Already at db version $dbversionnumber\n");
}
return 0;
}
else
{
print("LimeSurvey Commandline Install\n");
print("Usage: cmd_install <option> < <<path1>> <<path2>> >\n");
print("<option> - 'install' or 'upgrade' \n");
print("<<path1>> - Full path including filename to a custom config-defaults.php\n");
print("<<path2>> - Full path including filename to a custom common.php\n");
print("Paths are optional. If used both paths must be set.\n");
return 2;
}
?>

View File

@@ -1,4 +1,4 @@
-- phpSurveyor MS SQL Server 2000 database schema
-- LimeSurvey MS SQL Server 2000 database schema
-- --------------------------------------------------------
@@ -9,11 +9,21 @@ CREATE TABLE [prefix_quota] (
[qlimit] int ,
[action] int ,
[active] int NOT NULL default '1',
[autoload_url] int NOT NULL default '0',
PRIMARY KEY ([id])
);
CREATE TABLE [prefix_quota_languagesettings] (
[quotals_id] int NOT NULL IDENTITY (1,1),
[quotals_quota_id] int,
[quotals_language] varchar(45) NOT NULL default 'en',
[quotals_name] varchar(255),
[quotals_message] text,
[quotals_url] varchar(255),
[quotals_urldescrip] varchar(255),
PRIMARY KEY ([quotals_id])
);
CREATE TABLE [prefix_quota_members] (
@@ -21,7 +31,7 @@ CREATE TABLE [prefix_quota_members] (
[sid] int ,
[qid] int ,
[quota_id] int ,
[code] varchar(5) ,
[code] varchar(11) ,
PRIMARY KEY ([id])
);
@@ -35,9 +45,10 @@ CREATE TABLE [prefix_quota_members] (
CREATE TABLE [prefix_answers] (
[qid] INT NOT NULL default '0',
[code] VARCHAR(5) NOT NULL default '',
[answer] varchar(255) NOT NULL,
[answer] varchar(8000) NOT NULL,
[default_value] char(1) NOT NULL default 'N',
[sortorder] INT NOT NULL,
[assessment_value] INT NOT NULL default '0',
[language] VARCHAR(20) default 'en',
PRIMARY KEY ([qid],[code],[language])
)
@@ -58,8 +69,8 @@ CREATE TABLE [prefix_assessments] (
[minimum] VARCHAR(50) NOT NULL default '',
[maximum] VARCHAR(50) NOT NULL default '',
[message] text NOT NULL,
[link] text NOT NULL,
PRIMARY KEY ([id])
[language] VARCHAR(20) NOT NULL default 'en',
PRIMARY KEY ([id],[language])
)
;
@@ -72,6 +83,7 @@ CREATE TABLE [prefix_assessments] (
CREATE TABLE [prefix_conditions] (
[cid] INT NOT NULL IDENTITY (1,1),
[qid] INT NOT NULL default '0',
[scenario] INT NOT NULL default '1',
[cqid] INT NOT NULL default '0',
[cfieldname] VARCHAR(50) NOT NULL default '',
[method] char(2) NOT NULL default '',
@@ -107,6 +119,7 @@ CREATE TABLE [prefix_labels] (
[title] VARCHAR(4000),
[sortorder] INT NOT NULL,
[language] VARCHAR(20) default 'en',
[assessment_value] INT NOT NULL default '0',
PRIMARY KEY ([lid],[sortorder],[language]),
)
;
@@ -139,7 +152,7 @@ CREATE TABLE [prefix_question_attributes] (
[qaid] INT NOT NULL IDENTITY (1,1),
[qid] INT NOT NULL default '0',
[attribute] VARCHAR(50) default NULL,
[value] VARCHAR(20) default NULL,
[value] TEXT default NULL,
PRIMARY KEY ([qaid])
)
;
@@ -203,35 +216,38 @@ CREATE TABLE [prefix_surveys] (
[owner_id] INT NOT NULL,
[admin] VARCHAR(50) default NULL,
[active] char(1) NOT NULL default 'N',
[startdate] DATETIME default NULL,
[expires] DATETIME default NULL,
[adminemail] VARCHAR(320) default NULL,
[private] char(1) default NULL,
[faxto] VARCHAR(20) default NULL,
[format] char(1) default NULL,
[template] VARCHAR(100) default 'default',
[url] VARCHAR(255) default NULL,
[language] VARCHAR(50) default NULL,
[additional_languages] VARCHAR(255) default NULL,
[datestamp] char(1) default 'N',
[usecookie] char(1) default 'N',
[notification] char(1) default '0',
[allowregister] char(1) default 'N',
[attribute1] VARCHAR(255) default NULL,
[attribute2] VARCHAR(255) default NULL,
[allowsave] char(1) default 'Y',
[autonumber_start] bigINT default '0',
[autoredirect] char(1) default 'N',
[allowprev] char(1) default 'Y',
[printanswers] char(1) default 'N',
[ipaddr] char(1) default 'N',
[useexpiry] char(1) NOT NULL default 'N',
[refurl] char(1) default 'N',
[datecreated] DATETIME default NULL,
[listpublic] char(1) default 'N',
[publicstatistics] char(1) default 'N',
[publicgraphs] char(1) default 'N',
[htmlemail] char(1) default 'N',
[tokenanswerspersistence] char(1) default 'N',
[assessments] char(1) default 'N',
[usecaptcha] char(1) default 'N',
[usetokens] char(1) default 'N',
[bounce_email] VARCHAR(320) default NULL,
[attributedescriptions] text,
PRIMARY KEY ([sid])
)
;
@@ -249,6 +265,8 @@ CREATE TABLE [prefix_surveys_languagesettings] (
[surveyls_title] VARCHAR(200) NOT NULL,
[surveyls_description] TEXT NULL,
[surveyls_welcometext] TEXT NULL,
[surveyls_endtext] TEXT NULL,
[surveyls_url] VARCHAR(255) NULL,
[surveyls_urldescription] VARCHAR(255) NULL,
[surveyls_email_invite_subj] VARCHAR(255) NULL,
[surveyls_email_invite] TEXT NULL,
@@ -258,6 +276,7 @@ CREATE TABLE [prefix_surveys_languagesettings] (
[surveyls_email_register] TEXT NULL,
[surveyls_email_confirm_subj] VARCHAR(255) NULL,
[surveyls_email_confirm] TEXT NULL,
[surveyls_dateformat] INT NOT NULL DEFAULT 1,
PRIMARY KEY ([surveyls_survey_id],[surveyls_language])
)
;
@@ -269,7 +288,7 @@ CREATE TABLE [prefix_surveys_languagesettings] (
CREATE TABLE [prefix_users] (
[uid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[users_name] VARCHAR(64) NOT NULL UNIQUE default '',
[password] TEXT NOT NULL default '',
[password] varchar(8000) NOT NULL default '',
[full_name] VARCHAR(50) NOT NULL,
[parent_id] INT NOT NULL,
[lang] VARCHAR(20),
@@ -281,9 +300,11 @@ CREATE TABLE [prefix_users] (
[configurator] TINYINT NOT NULL default '0',
[manage_template] TINYINT NOT NULL default '0',
[manage_label] TINYINT NOT NULL default '0',
[htmleditormode] char(7) default 'default'
)
;
[htmleditormode] char(7) default 'default',
[one_time_pw] TEXT,
[dateformat] INT NOT NULL DEFAULT 1
);
--
-- Table structure for table [surveys_rights]
@@ -352,12 +373,30 @@ CREATE TABLE [prefix_templates] (
-- Table [settings_global]
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '126');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '138');
INSERT INTO [prefix_settings_global] VALUES ('SessionName', '$sessionname');
--
-- Table [users]
-- indexes
--
create index [answers_idx2] on [prefix_answers] ([sortorder]);
create index [assessments_idx2] on [prefix_assessments] ([sid]);
create index [assessments_idx3] on [prefix_assessments] ([gid]);
create index [conditions_idx2] on [prefix_conditions] ([qid]);
create index [conditions_idx3] on [prefix_conditions] ([cqid]);
create index [groups_idx2] on [prefix_groups] ([sid]);
create index [questions_idx2] on [prefix_questions] ([sid]);
create index [questions_idx3] on [prefix_questions] ([gid]);
create index [questions_idx4] on [prefix_questions] ([type]);
create index [question_attributes_idx2] on [prefix_question_attributes] ([qid]);
create index [quota_idx2] on [prefix_quota] ([sid]);
create index [saved_control_idx2] on [prefix_saved_control] ([sid]);
create index [user_in_groups_idx1] on [prefix_user_in_groups] ([ugid], [uid]);
--
-- Create the admin user
--
INSERT INTO [prefix_users] VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1,'default');
INSERT INTO [prefix_users] ([users_name], [password], [full_name], [parent_id], [lang] ,[email], [create_survey], [create_user] ,[delete_user] ,[superadmin] ,[configurator] ,[manage_template] , [manage_label]) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1);

View File

@@ -1,17 +1,3 @@
-- phpMyAdmin SQL Dump
-- version 2.8.0.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 23, 2006 at 07:56 PM
-- Server version: 5.0.20
-- PHP Version: 5.1.4
--
-- Database: `limesurvey-development`
--
--
-- Table structure for table `answers`
--
@@ -21,10 +7,11 @@ CREATE TABLE `prefix_answers` (
`code` varchar(5) NOT NULL default '',
`answer` text NOT NULL,
`default_value` char(1) NOT NULL default 'N',
`assessment_value` int(11) NOT NULL default '0',
`sortorder` int(11) NOT NULL,
`language` varchar(20) default 'en',
PRIMARY KEY (`qid`,`code`,`language`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -41,9 +28,9 @@ CREATE TABLE `prefix_assessments` (
`minimum` varchar(50) NOT NULL default '',
`maximum` varchar(50) NOT NULL default '',
`message` text NOT NULL,
`link` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
`language` varchar(20) NOT NULL default 'en',
PRIMARY KEY (`id`,`language`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -54,12 +41,13 @@ CREATE TABLE `prefix_assessments` (
CREATE TABLE `prefix_conditions` (
`cid` int(11) NOT NULL auto_increment,
`qid` int(11) NOT NULL default '0',
`scenario` int(11) NOT NULL default '1',
`cqid` int(11) NOT NULL default '0',
`cfieldname` varchar(50) NOT NULL default '',
`method` char(2) NOT NULL default '',
`value` varchar(255) NOT NULL default '',
PRIMARY KEY (`cid`)
) TYPE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
@@ -74,7 +62,7 @@ CREATE TABLE `prefix_groups` (
`description` text,
`language` varchar(20) default 'en',
PRIMARY KEY (`gid`,`language`)
) TYPE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -87,10 +75,11 @@ CREATE TABLE `prefix_labels` (
`code` varchar(5) NOT NULL default '',
`title` text,
`sortorder` int(11) NOT NULL,
`assessment_value` int(11) NOT NULL default '0',
`language` varchar(20) default 'en',
PRIMARY KEY (`lid`,`sortorder`,`language`),
KEY `ixcode` (`code`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -103,7 +92,7 @@ CREATE TABLE `prefix_labelsets` (
`label_name` varchar(100) NOT NULL default '',
`languages` varchar(200) default 'en',
PRIMARY KEY (`lid`)
) TYPE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -115,9 +104,9 @@ CREATE TABLE `prefix_question_attributes` (
`qaid` int(11) NOT NULL auto_increment,
`qid` int(11) NOT NULL default '0',
`attribute` varchar(50) default NULL,
`value` varchar(20) default NULL,
`value` text default NULL,
PRIMARY KEY (`qaid`)
) TYPE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -129,10 +118,25 @@ CREATE TABLE `prefix_quota` (
`qlimit` int(8) default NULL,
`action` int(2) default NULL,
`active` int(1) NOT NULL default '1',
`autoload_url` int(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table Structure for table quota_languagesettings
--
CREATE TABLE `prefix_quota_languagesettings` (
`quotals_id` int(11) NOT NULL auto_increment,
`quotals_quota_id` int(11) NOT NULL default '0',
`quotals_language` varchar(45) NOT NULL default 'en',
`quotals_name` varchar(255) collate utf8_unicode_ci default NULL,
`quotals_message` text NOT NULL,
`quotals_url` varchar(255),
`quotals_urldescrip` varchar(255),
PRIMARY KEY (`quotals_id`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
@@ -141,10 +145,10 @@ CREATE TABLE `prefix_quota_members` (
`sid` int(11) default NULL,
`qid` int(11) default NULL,
`quota_id` int(11) default NULL,
`code` varchar(5) collate utf8_unicode_ci default NULL,
`code` varchar(11) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sid` (`sid`,`qid`,`quota_id`,`code`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
@@ -167,7 +171,7 @@ CREATE TABLE `prefix_questions` (
`question_order` int(11) NOT NULL,
`language` varchar(20) default 'en',
PRIMARY KEY (`qid`,`language`)
) TYPE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -189,7 +193,7 @@ CREATE TABLE `prefix_saved_control` (
`saved_date` datetime NOT NULL,
`refurl` text,
PRIMARY KEY (`scid`)
) TYPE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
@@ -201,7 +205,7 @@ CREATE TABLE `prefix_settings_global` (
`stg_name` varchar(50) NOT NULL default '',
`stg_value` varchar(255) NOT NULL default '',
PRIMARY KEY (`stg_name`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
@@ -214,36 +218,38 @@ CREATE TABLE `prefix_surveys` (
`admin` varchar(50) default NULL,
`active` char(1) NOT NULL default 'N',
`expires` date default NULL,
`startdate` date default NULL,
`adminemail` varchar(320) default NULL,
`private` char(1) default NULL,
`faxto` varchar(20) default NULL,
`format` char(1) default NULL,
`template` varchar(100) default 'default',
`url` varchar(255) default NULL,
`language` varchar(50) default NULL,
`additional_languages` varchar(255) default NULL,
`datestamp` char(1) default 'N',
`usecookie` char(1) default 'N',
`notification` char(1) default '0',
`allowregister` char(1) default 'N',
`attribute1` varchar(255) default NULL,
`attribute2` varchar(255) default NULL,
`allowsave` char(1) default 'Y',
`autonumber_start` bigint(11) default '0',
`autoredirect` char(1) default 'N',
`allowprev` char(1) default 'Y',
`printanswers` char(1) default 'N',
`ipaddr` char(1) default 'N',
`useexpiry` char(1) NOT NULL default 'N',
`refurl` char(1) default 'N',
`datecreated` date default NULL,
`publicstatistics` char(1) default 'N',
`publicgraphs` char(1) default 'N',
`listpublic` char(1) default 'N',
`htmlemail` char(1) default 'N',
`tokenanswerspersistence` char(1) default 'N',
`assessments` char(1) default 'N',
`usecaptcha` char(1) default 'N',
`usetokens` char(1) default 'N',
`bounce_email` varchar(320) default NULL,
`attributedescriptions` text,
PRIMARY KEY (`sid`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
@@ -258,6 +264,8 @@ CREATE TABLE `prefix_surveys_languagesettings` (
`surveyls_title` VARCHAR(200) NOT NULL,
`surveyls_description` TEXT NULL,
`surveyls_welcometext` TEXT NULL,
`surveyls_endtext` TEXT NULL,
`surveyls_url` VARCHAR(255) NULL,
`surveyls_urldescription` VARCHAR(255) NULL,
`surveyls_email_invite_subj` VARCHAR(255) NULL,
`surveyls_email_invite` TEXT NULL,
@@ -267,6 +275,8 @@ CREATE TABLE `prefix_surveys_languagesettings` (
`surveyls_email_register` TEXT NULL,
`surveyls_email_confirm_subj` VARCHAR(255) NULL,
`surveyls_email_confirm` TEXT NULL,
`surveyls_dateformat` INT UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`surveyls_survey_id`, `surveyls_language`)
)
TYPE = $databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
@@ -286,7 +296,7 @@ CREATE TABLE `prefix_surveys_rights` (
`delete_survey` tinyint(1) NOT NULL default '0',
`activate_survey` tinyint(1) NOT NULL default '0',
PRIMARY KEY (sid, uid)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
@@ -295,14 +305,14 @@ CREATE TABLE `prefix_user_groups` (
`name` varchar(20) NOT NULL UNIQUE,
`description` TEXT NOT NULL,
`owner_id` int(10) unsigned NOT NULL
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `prefix_user_in_groups` (
`ugid` int(10) unsigned NOT NULL,
`uid` int(10) unsigned NOT NULL
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table structure for table `users`
@@ -323,8 +333,11 @@ CREATE TABLE `prefix_users` (
`configurator` tinyint(1) NOT NULL default '0',
`manage_template` tinyint(1) NOT NULL default '0',
`manage_label` tinyint(1) NOT NULL default '0',
`htmleditormode` varchar(7) default 'default'
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
`htmleditormode` varchar(7) default 'default',
`one_time_pw` BLOB,
`dateformat` INT UNSIGNED NOT NULL DEFAULT 1
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
@@ -334,25 +347,44 @@ CREATE TABLE `prefix_templates_rights` (
`folder` varchar(255) NOT NULL,
`use` int(1) NOT NULL,
PRIMARY KEY (`uid`,`folder`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `prefix_templates` (
`folder` varchar(255) NOT NULL,
`creator` int(11) NOT NULL,
PRIMARY KEY (`folder`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table `settings_global`
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '126');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '138');
INSERT INTO `prefix_settings_global` VALUES ('SessionName', '$sessionname');
--
-- Table `users`
--
INSERT INTO `prefix_users` VALUES (NULL, '$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1,'default');
INSERT INTO `prefix_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang` ,`email`, `create_survey`,`create_user` ,`delete_user` ,`superadmin` ,`configurator` ,`manage_template` , `manage_label`) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1);
--
-- indexes
--
create index `answers_idx2` on `prefix_answers` (`sortorder`);
create index `assessments_idx2` on `prefix_assessments` (`sid`);
create index `assessments_idx3` on `prefix_assessments` (`gid`);
create index `conditions_idx2` on `prefix_conditions` (`qid`);
create index `conditions_idx3` on `prefix_conditions` (`cqid`);
create index `groups_idx2` on `prefix_groups` (`sid`);
create index `question_attributes_idx2` on `prefix_question_attributes` (`qid`);
create index `questions_idx2` on `prefix_questions` (`sid`);
create index `questions_idx3` on `prefix_questions` (`gid`);
create index `questions_idx4` on `prefix_questions` (`type`);
create index `quota_idx2` on `prefix_quota` (`sid`);
create index `saved_control_idx2` on `prefix_saved_control` (`sid`);
create index `user_in_groups_idx1` on `prefix_user_in_groups` (`ugid`, `uid`);

View File

@@ -22,6 +22,7 @@ CREATE TABLE prefix_answers (
answer text NOT NULL,
default_value character(1) DEFAULT 'N'::bpchar NOT NULL,
sortorder integer NOT NULL,
assessment_value integer DEFAULT 0 NOT NULL,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL
);
@@ -41,7 +42,7 @@ CREATE TABLE prefix_assessments (
minimum character varying(50) DEFAULT ''::character varying NOT NULL,
maximum character varying(50) DEFAULT ''::character varying NOT NULL,
message text NOT NULL,
link text NOT NULL
language character(20) DEFAULT 'en'::bpchar NOT NULL
);
@@ -54,6 +55,7 @@ CREATE TABLE prefix_assessments (
CREATE TABLE prefix_conditions (
cid serial,
qid integer DEFAULT 0 NOT NULL,
scenario integer DEFAULT 1 NOT NULL,
cqid integer DEFAULT 0 NOT NULL,
cfieldname character varying(50) DEFAULT ''::character varying NOT NULL,
method character(2) DEFAULT ''::bpchar NOT NULL,
@@ -87,6 +89,7 @@ CREATE TABLE prefix_labels (
code character varying(5) DEFAULT ''::character varying NOT NULL,
title text,
sortorder integer NOT NULL,
assessment_value integer DEFAULT 0 NOT NULL,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL
);
@@ -115,7 +118,7 @@ CREATE TABLE prefix_question_attributes (
qaid serial NOT NULL,
qid integer DEFAULT 0 NOT NULL,
attribute character varying(50),
value character varying(20)
value text NULL
);
--
@@ -128,20 +131,33 @@ CREATE TABLE prefix_quota (
name character varying(255),
qlimit integer,
"action" integer,
"active" integer NOT NULL default '1'
"active" integer NOT NULL default '1',
autoload_url integer NOT NULL DEFAULT 0
);
ALTER TABLE ONLY prefix_quota
ADD CONSTRAINT prefix_quota_pkey PRIMARY KEY (id);
CREATE TABLE prefix_quota_languagesettings
(
quotals_id serial NOT NULL,
quotals_quota_id integer NOT NULL DEFAULT 0,
quotals_language character varying(45) NOT NULL DEFAULT 'en'::character varying,
quotals_name character varying(200),
quotals_message text NOT NULL,
quotals_url character varying(255),
quotals_urldescrip character varying(255)
);
ALTER TABLE ONLY prefix_quota_languagesettings
ADD CONSTRAINT prefix_quota_languagesettings_pkey PRIMARY KEY (quotals_id);
CREATE TABLE prefix_quota_members (
id serial,
sid integer,
qid integer,
quota_id integer,
code character varying(5)
code character varying(11)
);
ALTER TABLE ONLY prefix_quota_members
@@ -213,36 +229,37 @@ CREATE TABLE prefix_surveys (
owner_id integer NOT NULL,
"admin" character varying(50),
active character(1) DEFAULT 'N'::bpchar NOT NULL,
startdate date,
expires date,
adminemail character varying(320) NOT NULL,
private character(1),
faxto character varying(20),
format character(1),
"template" character varying(100) DEFAULT 'default'::character varying,
url character varying(255),
"language" character varying(50),
additional_languages character varying(255),
datestamp character(1) DEFAULT 'N'::bpchar,
usecookie character(1) DEFAULT 'N'::bpchar,
notification character(1) DEFAULT '0'::bpchar,
allowregister character(1) DEFAULT 'N'::bpchar,
attribute1 character varying(255),
attribute2 character varying(255),
allowsave character(1) DEFAULT 'Y'::bpchar,
printanswers character(1) DEFAULT 'N'::bpchar,
autonumber_start integer DEFAULT 0,
autoredirect character(1) DEFAULT 'N'::bpchar,
allowprev character(1) DEFAULT 'Y'::bpchar,
ipaddr character(1) DEFAULT 'N'::bpchar,
useexpiry character(1) DEFAULT 'N'::bpchar NOT NULL,
refurl character(1) DEFAULT 'N'::bpchar,
datecreated date,
listpublic character(1) DEFAULT 'N'::bpchar,
publicstatistics character(1) DEFAULT 'N'::bpchar,
publicgraphs character(1) DEFAULT 'N'::bpchar,
htmlemail character(1) DEFAULT 'N'::bpchar,
tokenanswerspersistence character(1) DEFAULT 'N'::bpchar,
assessments character(1) DEFAULT 'N'::bpchar,
usecaptcha character(1) DEFAULT 'N'::bpchar,
"bounce_email" character varying(320) NOT NULL
usetokens character(1) DEFAULT 'N'::bpchar,
"bounce_email" character varying(320) NOT NULL,
attributedescriptions text
);
@@ -258,7 +275,9 @@ CREATE TABLE prefix_surveys_languagesettings (
surveyls_title character varying(200) NOT NULL,
surveyls_description text,
surveyls_welcometext text,
surveyls_url character varying(255),
surveyls_urldescription character varying(255),
surveyls_endtext text,
surveyls_email_invite_subj character varying(255),
surveyls_email_invite text,
surveyls_email_remind_subj character varying(255),
@@ -266,7 +285,8 @@ CREATE TABLE prefix_surveys_languagesettings (
surveyls_email_register_subj character varying(255),
surveyls_email_register text,
surveyls_email_confirm_subj character varying(255),
surveyls_email_confirm text
surveyls_email_confirm text,
surveyls_dateformat integer DEFAULT 1 NOT NULL
);
@@ -310,8 +330,8 @@ CREATE TABLE prefix_user_in_groups (
--
CREATE TABLE prefix_users (
uid serial NOT NULL,
users_name character varying(64) DEFAULT ''::character varying NOT NULL,
uid serial PRIMARY KEY NOT NULL,
users_name character varying(64) DEFAULT ''::character varying UNIQUE NOT NULL,
"password" bytea NOT NULL,
full_name character varying(50) NOT NULL,
parent_id integer NOT NULL,
@@ -324,10 +344,11 @@ CREATE TABLE prefix_users (
configurator integer DEFAULT 0 NOT NULL,
manage_template integer DEFAULT 0 NOT NULL,
manage_label integer DEFAULT 0 NOT NULL,
htmleditormode character(7) DEFAULT 'default'::bpchar
htmleditormode character(7) DEFAULT 'default'::bpchar,
one_time_pw bytea,
"dateformat" integer DEFAULT 1 NOT NULL
);
CREATE TABLE prefix_templates_rights (
"uid" integer NOT NULL,
"folder" character varying(255) NOT NULL,
@@ -364,7 +385,7 @@ ALTER TABLE ONLY prefix_answers
--
ALTER TABLE ONLY prefix_assessments
ADD CONSTRAINT prefix_assessments_pkey PRIMARY KEY (id);
ADD CONSTRAINT prefix_assessments_pkey PRIMARY KEY (id,language);
--
@@ -489,11 +510,29 @@ CREATE INDEX prefix_labels_ixcode_idx ON prefix_labels USING btree (code);
-- Table `settings_global`
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '126');
INSERT INTO prefix_settings_global VALUES ('DBVersion', '138');
INSERT INTO prefix_settings_global VALUES ('SessionName', '$sessionname');
--
-- Table `users`
-- indexes
--
create index assessments_idx2 on prefix_assessments (sid);
create index assessments_idx3 on prefix_assessments (gid);
create index conditions_idx2 on prefix_conditions (qid);
create index groups_idx2 on prefix_groups (sid);
create index question_attributes_idx2 on prefix_question_attributes (qid);
create index questions_idx2 on prefix_questions (sid);
create index questions_idx3 on prefix_questions (gid);
create index quota_idx2 on prefix_quota (sid);
create index saved_control_idx2 on prefix_saved_control (sid);
create index user_in_groups_idx1 on prefix_user_in_groups (ugid, uid);
--
-- Create admin user
--
INSERT INTO prefix_users(
@@ -502,3 +541,7 @@ INSERT INTO prefix_users(
manage_template, manage_label,htmleditormode)
VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail',1,1,1,1,1,1,1,'default');

View File

@@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: createdb.php 4333 2008-02-25 13:19:12Z c_schmitz $
* $Id: createdb.php 7053 2009-06-10 10:43:43Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
@@ -32,8 +32,13 @@ echo "\t<tr bgcolor='#CCCCCC'><td align='center'>$setfont\n";
// In Step2 fill the database with data
if (returnglobal('createdbstep2')==$clang->gT("Populate Database"))
{
if ($databasetype=='mysql') {@$connect->Execute("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");} //Set the collation also for manually created DBs
if (modify_database(dirname(__FILE__).'/create-'.$databasetype.'.sql'))
$createdbtype=$databasetype;
if ($databasetype=='mysql' || $databasetype=='mysqli') {
@$connect->Execute("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");
$createdbtype='mysql';
}
if ($createdbtype=='mssql_n' || $createdbtype=='odbc_mssql' || $createdbtype=='odbtp') $createdbtype='mssql';
if (modify_database(dirname(__FILE__).'/create-'.$createdbtype.'.sql'))
{
echo sprintf($clang->gT("Database `%s` has been successfully populated."),$dbname)."</font></strong></font><br /><br />\n";
echo "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick='location.href=\"../$scriptname\"'>";
@@ -62,10 +67,12 @@ if (!$database_exists) //Database named in config-defaults.php does not exist
// TODO SQL: Portable to other databases??
switch ($databasetype)
{
case 'mysqli':
case 'mysql': $createDb=$connect->Execute("CREATE DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
break;
case 'mssql_n':
case 'odbc_mssql':
case 'mssql': $createDb=$connect->Execute("CREATE DATABASE [$dbname];");
case 'odbtp': $createDb=$connect->Execute("CREATE DATABASE [$dbname];");
break;
default: $createDb=$connect->Execute("CREATE DATABASE $dbname");
}

View File

@@ -1,34 +0,0 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Nicolas Barcet
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, 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: index.php 4729 2008-05-31 21:32:02Z nijaba $
*/
require_once(dirname(__FILE__).'/../../config-defaults.php');
require_once(dirname(__FILE__).'/../../common.php');
// SET THE LANGUAGE???? -> DEFAULT SET TO EN FOR NOW
require_once($rootdir.'/classes/core/language.php');
$clang = new limesurvey_lang("en");
ob_implicit_flush(true);
if ($databasetype=='mysql') {@$connect->Execute("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");} //Set the collation also for manually created DBs
if (modify_database(dirname(__FILE__).'/create-'.$databasetype.'.sql'))
{
print("Creating $dbname on $databasetype\n");
return 0;
} else {
print("Could not create $dbname on $databasetype\n");
return 1;
}
?>

View File

@@ -1,41 +0,0 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Nicolas Barcet
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, 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: index.php 4729 2008-05-31 21:32:02Z nijaba $
*/
require_once(dirname(__FILE__).'/../../config-defaults.php');
require_once(dirname(__FILE__).'/../../common.php');
// SET THE LANGUAGE???? -> DEFAULT SET TO EN FOR NOW
require_once($rootdir.'/classes/core/language.php');
$clang = new limesurvey_lang("en");
ob_implicit_flush(true);
global $connect, $databasetype, $dbprefix, $dbversionnumber, $clang;
include ('upgrade-'.$databasetype.'.php');
$tables = $connect->MetaTables();
$usquery = "SELECT stg_value FROM ".db_table_name("settings_global")." where stg_name='DBVersion'";
$usresult = db_execute_assoc($usquery);
$usrow = $usresult->FetchRow();
if (intval($usrow['stg_value'])<$dbversionnumber)
{
print("Upgrading db to $dbversionnumber\n");
db_upgrade(intval($usrow['stg_value']));
} else {
print("Already at db version $dbversionnumber\n");
}
return 0;
?>

View File

@@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: index.php 4346 2008-02-25 21:32:02Z c_schmitz $
* $Id: index.php 6952 2009-05-27 09:40:07Z c_schmitz $
*/
@@ -60,7 +60,7 @@ else
$connect->database = $databasename;
$connect->Execute("USE DATABASE `$databasename`");
$output=checkforupgrades();
if (!isset($ouput)) {$adminoutput.='<br />LimeSurvey Database is up to date. No action needed';}
if ($output== '') {$adminoutput.='<br />LimeSurvey Database is up to date. No action needed';}
else {$adminoutput.=$output;}
$adminoutput.="<br />Please <a href='$homeurl/$scriptname'>log in.</a>";
@@ -73,7 +73,10 @@ function checkforupgrades()
{
global $connect, $databasetype, $dbprefix, $dbversionnumber, $clang;
$adminoutput='';
include ('upgrade-'.$databasetype.'.php');
$upgradedbtype=$databasetype;
if ($upgradedbtype=='mssql_n' || $upgradedbtype=='odbc_mssql' || $upgradedbtype=='odbtp') $upgradedbtype='mssql';
if ($upgradedbtype=='mysqli') $upgradedbtype='mysql';
include ('upgrade-'.$upgradedbtype.'.php');
$tables = $connect->MetaTables();
$usquery = "SELECT stg_value FROM ".db_table_name("settings_global")." where stg_name='DBVersion'";

View File

@@ -22,14 +22,17 @@ sendcacheheaders();
switch ($databasetype)
{
case 'mysql': modify_database("",'UPDATE `prefix_users` set password=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'odbc_mssql':modify_database("",'UPDATE [prefix_users] set password=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'postgres':modify_database("",'UPDATE prefix_users set \"password\"=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'mysqli':
case 'mysql' : modify_database("",'UPDATE `prefix_users` set password=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'odbtp':
case 'mssql_n':
case 'odbc_mssql':modify_database("",'UPDATE [prefix_users] set password=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'postgres':modify_database("",'UPDATE prefix_users set \"password\"=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
}
?>

View File

@@ -0,0 +1,445 @@
<?PHP
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, 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: upgrade-mssql.php 7122 2009-06-16 13:42:29Z c_schmitz $
*/
// There will be a file for each database (accordingly named to the dbADO scheme)
// where based on the current database version the database is upgraded
// For this there will be a settings table which holds the last time the database was upgraded
function db_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput, $dbprefix;
echo str_pad('Loading... ',4096)."<br />\n";
if ($oldversion < 111) {
// Language upgrades from version 110 to 111 since the language names did change
$oldnewlanguages=array('german_informal'=>'german-informal',
'cns'=>'cn-Hans',
'cnt'=>'cn-Hant',
'pt_br'=>'pt-BR',
'gr'=>'el',
'jp'=>'ja',
'si'=>'sl',
'se'=>'sv',
'vn'=>'vi');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update [prefix_answers] set [language`='$newlang' where language='$oldlang'"); echo $modifyoutput; flush();
modify_database("","update [prefix_questions] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_groups] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_labels] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_language`='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_users] set [lang`='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update [prefix_labelsets] set [languages`='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update [prefix_surveys] set [additional_languages`='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();
}
modify_database("","update [prefix_settings_global] set [stg_value]='111' where stg_name='DBVersion'"); echo $modifyoutput;
}
if ($oldversion < 112) {
//The size of the users_name field is now 64 char (20 char before version 112)
modify_database("","ALTER TABLE [prefix_users] ALTER COLUMN [users_name] VARCHAR( 64 ) NOT NULL"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='112' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 113) {
//No action needed
modify_database("","update [prefix_settings_global] set [stg_value]='113' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 114) {
modify_database("","ALTER TABLE [prefix_saved_control] ALTER COLUMN [email] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ALTER COLUMN [adminemail] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_users] ALTER COLUMN [email] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("",'INSERT INTO [prefix_settings_global] VALUES (\'SessionName\', \'$sessionname\');');echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='114' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 126) {
modify_database("","ALTER TABLE [prefix_surveys] ADD [printanswers] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [listpublic] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
upgrade_survey_tables117();
upgrade_survey_tables118();
//119
modify_database("","CREATE TABLE [prefix_quota] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int,
[name] varchar(255) ,
[qlimit] int ,
[action] int ,
[active] int NOT NULL default '1',
PRIMARY KEY ([id])
);");echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_quota_members] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
[qid] int ,
[quota_id] int ,
[code] varchar(5) ,
PRIMARY KEY ([id])
);");echo $modifyoutput; flush();
// Rename Norwegian language code from NO to NB
$oldnewlanguages=array('no'=>'nb');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update [prefix_answers] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_questions] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_groups] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_labels] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_language]='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_users] set [lang]='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update [prefix_labelsets] set [languages]='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();}
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update [prefix_surveys] set [additional_languages]='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();}
}
modify_database("","ALTER TABLE [prefix_surveys] ADD [htmlemail] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [usecaptcha] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [tokenanswerspersistence] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_users] ADD [htmleditormode] CHAR(7) DEFAULT 'default'"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_templates_rights] (
[uid] int NOT NULL,
[folder] varchar(255) NOT NULL,
[use] int NOT NULL,
PRIMARY KEY ([uid],[folder])
);");echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_templates] (
[folder] varchar(255) NOT NULL,
[creator] int NOT NULL,
PRIMARY KEY ([folder])
);");echo $modifyoutput; flush();
//123
modify_database("","ALTER TABLE [prefix_conditions] ALTER COLUMN [value] VARCHAR(255)"); echo $modifyoutput; flush();
// There is no other way to remove the previous default value
/*modify_database("","DECLARE @STR VARCHAR(100)
SET @STR = (
SELECT NAME
FROM SYSOBJECTS SO
JOIN SYSCONSTRAINTS SC ON SO.ID = SC.CONSTID
WHERE OBJECT_NAME(SO.PARENT_OBJ) = 'lime_labels'
AND SO.XTYPE = 'D' AND SC.COLID =
(SELECT COLID FROM SYSCOLUMNS WHERE ID = OBJECT_ID('lime_labels') AND NAME = 'title'))
SET @STR = 'ALTER TABLE lime_labels DROP CONSTRAINT ' + @STR
exec (@STR);"); echo $modifyoutput; flush(); */
modify_database("","ALTER TABLE [prefix_labels] ALTER COLUMN [title] varchar(4000)"); echo $modifyoutput; flush();
//124
modify_database("","ALTER TABLE [prefix_surveys] ADD [bounce_email] text"); echo $modifyoutput; flush();
//125
upgrade_token_tables125();
modify_database("","EXEC sp_rename 'prefix_users.move_user','superadmin'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_users] SET [superadmin]=1 where ([create_survey]=1 AND [create_user]=1 AND [delete_user]=1 AND [configurator]=1)"); echo $modifyoutput; flush();
//126
modify_database("","ALTER TABLE [prefix_questions] ADD [lid1] int NOT NULL DEFAULT '0'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_conditions] SET [method]='==' where ( [method] is null) or [method]='' or [method]='0'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='126' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 127) {
modify_database("","create index [answers_idx2] on [prefix_answers] ([sortorder])"); echo $modifyoutput;
modify_database("","create index [assessments_idx2] on [prefix_assessments] ([sid])"); echo $modifyoutput;
modify_database("","create index [assessments_idx3] on [prefix_assessments] ([gid])"); echo $modifyoutput;
modify_database("","create index [conditions_idx2] on [prefix_conditions] ([qid])"); echo $modifyoutput;
modify_database("","create index [conditions_idx3] on [prefix_conditions] ([cqid])"); echo $modifyoutput;
modify_database("","create index [groups_idx2] on [prefix_groups] ([sid])"); echo $modifyoutput;
modify_database("","create index [question_attributes_idx2] on [prefix_question_attributes] ([qid])"); echo $modifyoutput;
modify_database("","create index [questions_idx2] on [prefix_questions] ([sid])"); echo $modifyoutput;
modify_database("","create index [questions_idx3] on [prefix_questions] ([gid])"); echo $modifyoutput;
modify_database("","create index [questions_idx4] on [prefix_questions] ([type])"); echo $modifyoutput;
modify_database("","create index [quota_idx2] on [prefix_quota] ([sid])"); echo $modifyoutput;
modify_database("","create index [saved_control_idx2] on [prefix_saved_control] ([sid])"); echo $modifyoutput;
modify_database("","create index [user_in_groups_idx1] on [prefix_user_in_groups] ([ugid], [uid])"); echo $modifyoutput;
modify_database("","update [prefix_settings_global] set [stg_value]='127' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 128) {
upgrade_token_tables128();
modify_database("","update [prefix_settings_global] set [stg_value]='128' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 129) {
//128
modify_database("","ALTER TABLE [prefix_surveys] ADD [startdate] DATETIME"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [usestartdate] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='129' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 130)
{
modify_database("","ALTER TABLE [prefix_conditions] ADD [scenario] int NOT NULL DEFAULT '1'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_conditions] SET [scenario]=1 where ( [scenario] is null) or [scenario]='' or [scenario]=0"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='130' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 131)
{
modify_database("","ALTER TABLE [prefix_surveys] ADD [publicstatistics] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='131' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 132)
{
modify_database("","ALTER TABLE [prefix_surveys] ADD [publicgraphs] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='132' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 133)
{
modify_database("","ALTER TABLE [prefix_users] ADD [one_time_pw] text"); echo $modifyoutput; flush();
// Add new assessment setting
modify_database("","ALTER TABLE [prefix_surveys] ADD [assessments] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
// add new assessment value fields to answers & labels
modify_database("","ALTER TABLE [prefix_answers] ADD [assessment_value] int NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_labels] ADD [assessment_value] int NOT NULL default '0'"); echo $modifyoutput; flush();
// copy any valid codes from code field to assessment field
modify_database("","update [prefix_answers] set [assessment_value]=CAST([code] as int)");// no output here is intended
modify_database("","update [prefix_labels] set [assessment_value]=CAST([code] as int)");// no output here is intended
// activate assessment where assesment rules exist
modify_database("","update [prefix_surveys] set [assessments]='Y' where [sid] in (SELECT [sid] FROM [prefix_assessments] group by [sid])"); echo $modifyoutput; flush();
// add language field to assessment table
modify_database("","ALTER TABLE [prefix_assessments] ADD [language] varchar(20) NOT NULL default 'en'"); echo $modifyoutput; flush();
// update language field with default language of that particular survey
modify_database("","update [prefix_assessments] set [language]=(select [language] from [prefix_surveys] where [sid]=[prefix_assessments].[sid])"); echo $modifyoutput; flush();
// copy assessment link to message since from now on we will have HTML assignment messages
modify_database("","update [prefix_assessments] set [message]=cast([message] as varchar) +'<br /><a href=\"'+[link]+'\">'+[link]+'</a>'"); echo $modifyoutput; flush();
// drop the old link field
modify_database("","ALTER TABLE [prefix_assessments] DROP COLUMN [link]"); echo $modifyoutput; flush();
// change the primary index to include language
// and fix missing translations for assessments
upgrade_survey_tables133a();
// Add new fields to survey language settings
modify_database("","ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_url] varchar(255)"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_endtext] text"); echo $modifyoutput; flush();
// copy old URL fields ot language specific entries
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_url]=(select [url] from [prefix_surveys] where [sid]=[prefix_surveys_languagesettings].[surveyls_survey_id])"); echo $modifyoutput; flush();
// drop old URL field
mssql_drop_constraint('url','surveys');
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [url]"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='133' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 134)
{
// Add new assessment setting
modify_database("","ALTER TABLE [prefix_surveys] ADD [usetokens] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
mssql_drop_constraint('attribute1','surveys');
mssql_drop_constraint('attribute2','surveys');
modify_database("", "ALTER TABLE [prefix_surveys] ADD [attributedescriptions] TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [attribute1]"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [attribute2]"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update [prefix_settings_global] set [stg_value]='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
{
mssql_drop_constraint('value','question_attributes');
modify_database("","ALTER TABLE [prefix_question_attributes] ALTER COLUMN [value] text"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_answers] ALTER COLUMN [answer] varchar(8000)"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='135' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 136) //New quota functions
{
modify_database("", "ALTER TABLE[prefix_quota] ADD [autoload_url] int NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_quota_languagesettings] (
[quotals_id] int NOT NULL IDENTITY (1,1),
[quotals_quota_id] int,
[quotals_language] varchar(45) NOT NULL default 'en',
[quotals_name] varchar(255),
[quotals_message] text,
[quotals_url] varchar(255),
[quotals_urldescrip] varchar(255),
PRIMARY KEY ([quotals_id])
);");echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='136' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 137) //New date format specs
{
modify_database("", "ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_dateformat] int NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE [prefix_users] ADD [dateformat] int NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "update [prefix_surveys] set startdate=null where usestartdate='N'"); echo $modifyoutput; flush();
modify_database("", "update [prefix_surveys] set expires=null where useexpiry='N'"); echo $modifyoutput; flush();
mssql_drop_constraint('usestartdate','surveys');
mssql_drop_constraint('useexpiry','surveys');
modify_database("", "ALTER TABLE [prefix_surveys] DROP COLUMN usestartdate"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE [prefix_surveys] DROP COLUMN useexpiry"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='137' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 138) //Modify quota field
{
modify_database("", "ALTER TABLE [prefix_quota_members] ALTER COLUMN [code] VARCHAR(11) NULL"); echo $modifyoutput; flush();
modify_database("", "UPDATE [prefix_settings_global] SET [stg_value]='138' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
return true;
}
function upgrade_survey_tables117()
{
global $modifyoutput;
$surveyidquery = "SELECT sid FROM ".db_table_name('surveys')." WHERE active='Y' and datestamp='Y'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".db_table_name('survey_'.$sv[0])." ADD [startdate] datetime"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables118()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ALTER COLUMN [token] VARCHAR(36)"); echo $modifyoutput; flush();
}
}
function upgrade_token_tables125()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD [emailstatus] VARCHAR(300) DEFAULT 'OK'"); echo $modifyoutput; flush();
}
}
function upgrade_token_tables128()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD [remindersent] VARCHAR(17) DEFAULT 'OK'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [remindercount] int DEFAULT '0'"); echo $modifyoutput; flush();
}
}
function upgrade_survey_tables133a()
{
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}assessments') AND (CONSTRAINT_TYPE = 'PRIMARY KEY')";
$primarykey=$connect->GetRow($pkquery);
if ($primarykey!=false)
{
modify_database("","ALTER TABLE [prefix_assessments] DROP CONSTRAINT {$primarykey[0]}"); echo $modifyoutput; flush();
}
// add the new primary key
modify_database("","ALTER TABLE [prefix_assessments] ADD CONSTRAINT pk_assessments_id_lang PRIMARY KEY ([id],[language])"); echo $modifyoutput; flush();
$surveyidquery = "SELECT sid,additional_languages FROM ".db_table_name('surveys');
$surveyidresult = db_execute_num($surveyidquery);
while ( $sv = $surveyidresult->FetchRow() )
{
FixLanguageConsistency($sv[0],$sv[1]);
}
}
function upgrade_token_tables134()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD [validfrom] DATETIME"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [validuntil] DATETIME"); echo $modifyoutput; flush();
}
}
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?
// It proves how badly designer some Microsoft software is!
$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();
}
}
?>

View File

@@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: upgrade-mysql.php 4467 2008-03-16 21:19:53Z c_schmitz $
* $Id: upgrade-mysql.php 7108 2009-06-15 05:43:21Z jcleeland $
*/
// There will be a file for each database (accordingly named to the dbADO scheme)
@@ -115,12 +115,12 @@ echo str_pad('Loading... ',4096)."<br />\n";
modify_database("","CREATE TABLE `prefix_quota` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`qlimit` int(8) default NULL,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`action` int(2) default NULL,
`active` int(1) NOT NULL default '1',
PRIMARY KEY (`id`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE `prefix_quota_members` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
@@ -129,7 +129,7 @@ echo str_pad('Loading... ',4096)."<br />\n";
`code` varchar(5) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sid` (`sid`,`qid`,`quota_id`,`code`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
// Rename Norwegian language code from NO to NB
$oldnewlanguages=array('no'=>'nb');
@@ -169,12 +169,12 @@ echo str_pad('Loading... ',4096)."<br />\n";
`folder` varchar(255) NOT NULL,
`use` int(1) NOT NULL,
PRIMARY KEY (`uid`,`folder`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE `prefix_templates` (
`folder` varchar(255) NOT NULL,
`creator` int(11) NOT NULL,
PRIMARY KEY (`folder`)
) TYPE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
//123
modify_database("","ALTER TABLE `prefix_conditions` CHANGE `value` `value` VARCHAR(255) NOT NULL default ''"); echo $modifyoutput; flush();
@@ -188,16 +188,140 @@ echo str_pad('Loading... ',4096)."<br />\n";
modify_database("","ALTER TABLE `prefix_users` DROP COLUMN `move_user`"); echo $modifyoutput; flush();
//126
modify_database("","ALTER TABLE `prefix_questions` ADD `lid1` integer NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_conditions` SET `method`='==' where (`method` is null) or `method`=''"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_conditions` SET `method`='==' where (`method` is null) or `method`='' or `method`='0'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='126' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 127) {
modify_database("","create index `assessments_idx2` on `prefix_assessments` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `assessments_idx3` on `prefix_assessments` (`gid`)"); echo $modifyoutput; flush();
modify_database("","create index `conditions_idx2` on `prefix_conditions` (`qid`)"); echo $modifyoutput; flush();
modify_database("","create index `groups_idx2` on `prefix_groups` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `questions_idx2` on `prefix_questions` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `questions_idx3` on `prefix_questions` (`gid`)"); echo $modifyoutput; flush();
modify_database("","create index `question_attributes_idx2` on `prefix_question_attributes` (`qid`)"); echo $modifyoutput; flush();
modify_database("","create index `quota_idx2` on `prefix_quota` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `saved_control_idx2` on `prefix_saved_control` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `user_in_groups_idx1` on `prefix_user_in_groups` (`ugid`, `uid`)"); echo $modifyoutput; flush();
modify_database("","create index `answers_idx2` on `prefix_answers` (`sortorder`)"); echo $modifyoutput; flush();
modify_database("","create index `conditions_idx3` on `prefix_conditions` (`cqid`)"); echo $modifyoutput; flush();
modify_database("","create index `questions_idx4` on `prefix_questions` (`type`)"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='127' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 128) {
//128
upgrade_token_tables128();
modify_database("","update `prefix_settings_global` set `stg_value`='128' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 129) {
//129
modify_database("","ALTER TABLE `prefix_surveys` ADD `startdate` DATETIME"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `usestartdate` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='129' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 130)
{
modify_database("","ALTER TABLE `prefix_conditions` ADD `scenario` integer NOT NULL default '1' AFTER `qid`"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_conditions` SET `scenario`=1 where (`scenario` is null) or `scenario`='' or `scenario`=0"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='130' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 131)
{
modify_database("","ALTER TABLE `prefix_surveys` ADD `publicstatistics` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='131' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 132)
{
modify_database("","ALTER TABLE `prefix_surveys` ADD `publicgraphs` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='132' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 133)
{
modify_database("","ALTER TABLE `prefix_users` ADD `one_time_pw` blob"); echo $modifyoutput; flush();
// Add new assessment setting
modify_database("","ALTER TABLE `prefix_surveys` ADD `assessments` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
// add new assessment value fields to answers & labels
modify_database("","ALTER TABLE `prefix_answers` ADD `assessment_value` int(11) NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_labels` ADD `assessment_value` int(11) NOT NULL default '0'"); echo $modifyoutput; flush();
// copy any valid codes from code field to assessment field
modify_database("","update `prefix_answers` set `assessment_value`=CAST(`code` as SIGNED) where `code` REGEXP '^-?[0-9]+$'");echo $modifyoutput; flush();
modify_database("","update `prefix_labels` set `assessment_value`=CAST(`code` as SIGNED) where `code` REGEXP '^-?[0-9]+$'");echo $modifyoutput; flush();
// activate assessment where assesment rules exist
modify_database("","update `prefix_surveys` set `assessments`='Y' where `sid` in (SELECT `sid` FROM `prefix_assessments` group by `sid`)"); echo $modifyoutput; flush();
// add language field to assessment table
modify_database("","ALTER TABLE `prefix_assessments` ADD `language` varchar(20) NOT NULL default 'en'"); echo $modifyoutput; flush();
// update language field with default language of that particular survey
modify_database("","update `prefix_assessments` set `language`=(select `language` from `prefix_surveys` where `sid`=`prefix_assessments`.`sid`)"); echo $modifyoutput; flush();
// copy assessment link to message since from now on we will have HTML assignment messages
modify_database("","update `prefix_assessments` set `message`=concat(replace(`message`,'/''',''''),'<br /><a href=\"',`link`,'\">',`link`,'</a>')"); echo $modifyoutput; flush();
// drop the old link field
modify_database("","ALTER TABLE `prefix_assessments` DROP COLUMN `link`"); echo $modifyoutput; flush();
// change the primary index to include language
modify_database("","ALTER TABLE `prefix_assessments` DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(`id`, `language`)"); echo $modifyoutput; flush();
//finally fix missing translations for assessments
upgrade_survey_tables133();
// Add new fields to survey language settings
modify_database("","ALTER TABLE `prefix_surveys_languagesettings` ADD `surveyls_url` varchar(255)"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys_languagesettings` ADD `surveyls_endtext` text"); echo $modifyoutput; flush();
// copy old URL fields ot language specific entries
modify_database("","update `prefix_surveys_languagesettings` set `surveyls_url`=(select `url` from `prefix_surveys` where `sid`=`prefix_surveys_languagesettings`.`surveyls_survey_id`)"); echo $modifyoutput; flush();
// drop old URL field
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `url`"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='133' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 134)
{
// Add new tokens setting
modify_database("","ALTER TABLE `prefix_surveys` ADD `usetokens` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `attributedescriptions` TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `attribute1`"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `attribute2`"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update `prefix_settings_global` set `stg_value`='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
{
modify_database("","ALTER TABLE `prefix_question_attributes` MODIFY `value` text"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_settings_global` SET `stg_value`='135' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 136) //New Quota Functions
{
modify_database("","ALTER TABLE `prefix_quota` ADD `autoload_url` int(1) NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE `prefix_quota_languagesettings` (
`quotals_id` int(11) NOT NULL auto_increment,
`quotals_quota_id` int(11) NOT NULL default '0',
`quotals_language` varchar(45) NOT NULL default 'en',
`quotals_name` varchar(255) collate utf8_unicode_ci default NULL,
`quotals_message` text NOT NULL,
`quotals_url` varchar(255),
`quotals_urldescrip` varchar(255),
PRIMARY KEY (`quotals_id`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_settings_global` SET `stg_value`='136' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 137) //New Quota Functions
{
modify_database("", "ALTER TABLE `prefix_surveys_languagesettings` ADD `surveyls_dateformat` int(1) NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_users` ADD `dateformat` int(1) NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_surveys` set `startdate`=null where `usestartdate`='N'"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_surveys` set `expires`=null where `useexpiry`='N'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_surveys` DROP COLUMN `useexpiry`"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_surveys` DROP COLUMN `usestartdate`"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='137' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 138) //Modify quota field
{
modify_database("", "ALTER TABLE `prefix_quota_members` CHANGE `code` `code` VARCHAR(11) collate utf8_unicode_ci default NULL"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='138' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
return true;
}
function upgrade_survey_tables117()
{
global $modifyoutput;
@@ -205,12 +329,12 @@ function upgrade_survey_tables117()
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
{
while ( $sv = $surveyidresult->FetchRow() )
{
{
modify_database("","ALTER TABLE ".db_table_name('survey_'.$sv[0])." ADD `startdate` datetime AFTER `datestamp`"); echo $modifyoutput; flush();
}
}
}
}
function upgrade_survey_tables118()
@@ -238,61 +362,105 @@ function upgrade_token_tables125()
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD `emailstatus` varchar(255) NOT NULL DEFAULT 'OK'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD `emailstatus` varchar(300) NOT NULL DEFAULT 'OK'"); echo $modifyoutput; flush();
}
}
}
// Add the reminders tracking fields
function upgrade_token_tables128()
{
global $modifyoutput,$dbprefix;
$surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD `remindersent` VARCHAR(17) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD `remindercount` INT(11) DEFAULT 0"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables133()
{
$surveyidquery = "SELECT sid,additional_languages FROM ".db_table_name('surveys');
$surveyidresult = db_execute_num($surveyidquery);
while ( $sv = $surveyidresult->FetchRow() )
{
FixLanguageConsistency($sv[0],$sv[1]);
}
}
// Add the reminders tracking fields
function upgrade_token_tables134()
{
global $modifyoutput,$dbprefix;
$surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD `validfrom` Datetime"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD `validuntil` Datetime"); echo $modifyoutput; flush();
}
}
}
function fix_mysql_collation()
{
global $connect, $modifyoutput, $dbprefix;
$sql = 'SHOW TABLE STATUS';
$result = db_execute_assoc($sql);
if (!$result) {
$modifyoutput .= 'SHOW TABLE - SQL Error';
global $connect, $modifyoutput, $dbprefix;
$sql = 'SHOW TABLE STATUS';
$result = db_execute_assoc($sql);
if (!$result) {
$modifyoutput .= 'SHOW TABLE - SQL Error';
}
while ( $tables = $result->FetchRow() ) {
// Loop through all tables in this database
$table = $tables['Name'];
$tablecollation=$tables['Collation'];
if (strpos($table,'old_')===false && ($dbprefix=='' || ($dbprefix!='' && strpos($table,$dbprefix)!==false)))
{
if ($tablecollation!='utf8_unicode_ci')
{
modify_database("","ALTER TABLE $table COLLATE utf8_unicode_ci");
echo $modifyoutput; flush();
}
# Now loop through all the fields within this table
$result2 = db_execute_assoc("SHOW FULL COLUMNS FROM ".$table);
while ( $column = $result2->FetchRow())
{
if ($column['Collation']!= 'utf8_unicode_ci' )
{
$field_name = $column['Field'];
$field_type = $column['Type'];
$field_default = $column['Default'];
if ($field_default!='NULL') {$field_default="'".$field_default."'";}
# Change text based fields
$skipped_field_types = array('char', 'text', 'enum', 'set');
foreach ( $skipped_field_types as $type )
{
if ( strpos($field_type, $type) !== false )
{
$modstatement="ALTER TABLE $table CHANGE `$field_name` `$field_name` $field_type CHARACTER SET utf8 COLLATE utf8_unicode_ci";
if ($type!='text') {$modstatement.=" DEFAULT $field_default";}
modify_database("",$modstatement);
echo $modifyoutput; flush();
}
}
}
}
}
}
while ( $tables = $result->FetchRow() ) {
// Loop through all tables in this database
$table = $tables['Name'];
$tablecollation=$tables['Collation'];
if (strpos($table,'old_')===false && ($dbprefix=='' || ($dbprefix!='' && strpos($table,$dbprefix)!==false)))
{
if ($tablecollation!='utf8_unicode_ci')
{
modify_database("","ALTER TABLE $table COLLATE utf8_unicode_ci");
echo $modifyoutput; flush();
}
# Now loop through all the fields within this table
$result2 = db_execute_assoc("SHOW FULL COLUMNS FROM ".$table);
while ( $column = $result2->FetchRow())
{
if ($column['Collation']!= 'utf8_unicode_ci' )
{
$field_name = $column['Field'];
$field_type = $column['Type'];
$field_default = $column['Default'];
if ($field_default!='NULL') {$field_default="'".$field_default."'";}
# Change text based fields
$skipped_field_types = array('char', 'text', 'enum', 'set');
foreach ( $skipped_field_types as $type )
{
if ( strpos($field_type, $type) !== false )
{
$modstatement="ALTER TABLE $table CHANGE `$field_name` `$field_name` $field_type CHARACTER SET utf8 COLLATE utf8_unicode_ci";
if ($type!='text') {$modstatement.=" DEFAULT $field_default";}
modify_database("",$modstatement);
echo $modifyoutput; flush();
}
}
}
}
}
}
}
?>

View File

@@ -1,240 +0,0 @@
<?PHP
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, 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: upgrade-odbc_mssql.php 4453 2008-03-13 22:41:44Z c_schmitz $
*/
// There will be a file for each database (accordingly named to the dbADO scheme)
// where based on the current database version the database is upgraded
// For this there will be a settings table which holds the last time the database was upgraded
function db_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput;
echo str_pad('Loading... ',4096)."<br />\n";
if ($oldversion < 111) {
// Language upgrades from version 110 to 111 since the language names did change
$oldnewlanguages=array('german_informal'=>'german-informal',
'cns'=>'cn-Hans',
'cnt'=>'cn-Hant',
'pt_br'=>'pt-BR',
'gr'=>'el',
'jp'=>'ja',
'si'=>'sl',
'se'=>'sv',
'vn'=>'vi');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update [prefix_answers] set [language`='$newlang' where language='$oldlang'"); echo $modifyoutput; flush();
modify_database("","update [prefix_questions] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_groups] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_labels] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_language`='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_users] set [lang`='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update [prefix_labelsets] set [languages`='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update [prefix_surveys] set [additional_languages`='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();
}
modify_database("","update [prefix_settings_global] set [stg_value`='111' where stg_name='DBVersion'"); echo $modifyoutput;
}
if ($oldversion < 112) {
//The size of the users_name field is now 64 char (20 char before version 112)
modify_database("","ALTER TABLE [prefix_users] ALTER COLUMN [users_name] VARCHAR( 64 ) NOT NULL"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value`='112' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 113) {
//No action needed
modify_database("","update [prefix_settings_global] set [stg_value]='113' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 114) {
modify_database("","ALTER TABLE [prefix_saved_control] ALTER COLUMN [email] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ALTER COLUMN [adminemail] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_users] ALTER COLUMN [email] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("",'INSERT INTO [prefix_settings_global] VALUES (\'SessionName\', \'$sessionname\');');echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='114' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 126) {
modify_database("","ALTER TABLE [prefix_surveys] ADD [printanswers] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [listpublic] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
upgrade_survey_tables117();
upgrade_survey_tables118();
//119
modify_database("","CREATE TABLE [prefix_quota] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int,
[name] varchar(255) ,
[qlimit] int ,
[action] int ,
[active] int NOT NULL default '1',
PRIMARY KEY ([id])
);");echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_quota_members] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
[qid] int ,
[quota_id] int ,
[code] varchar(5) ,
PRIMARY KEY ([id])
);");echo $modifyoutput; flush();
// Rename Norwegian language code from NO to NB
$oldnewlanguages=array('no'=>'nb');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update [prefix_answers] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_questions] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_groups] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_labels] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_language]='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_users] set [lang]='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update [prefix_labelsets] set [languages]='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();}
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update [prefix_surveys] set [additional_languages]='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();}
}
modify_database("","ALTER TABLE [prefix_surveys] ADD [htmlemail] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [usecaptcha] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [tokenanswerspersistence] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_users] ADD [htmleditormode] CHAR(7) DEFAULT 'default'"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_templates_rights] (
[uid] int NOT NULL,
[folder] varchar(255) NOT NULL,
[use] int NOT NULL,
PRIMARY KEY ([uid],[folder])
);");echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_templates] (
[folder] varchar(255) NOT NULL,
[creator] int NOT NULL,
PRIMARY KEY ([folder])
);");echo $modifyoutput; flush();
//123
modify_database("","ALTER TABLE [prefix_conditions] ALTER COLUMN [value] VARCHAR(255)"); echo $modifyoutput; flush();
// There is no other way to remove the previous default value
/*modify_database("","DECLARE @STR VARCHAR(100)
SET @STR = (
SELECT NAME
FROM SYSOBJECTS SO
JOIN SYSCONSTRAINTS SC ON SO.ID = SC.CONSTID
WHERE OBJECT_NAME(SO.PARENT_OBJ) = 'lime_labels'
AND SO.XTYPE = 'D' AND SC.COLID =
(SELECT COLID FROM SYSCOLUMNS WHERE ID = OBJECT_ID('lime_labels') AND NAME = 'title'))
SET @STR = 'ALTER TABLE lime_labels DROP CONSTRAINT ' + @STR
exec (@STR);"); echo $modifyoutput; flush(); */
modify_database("","ALTER TABLE [prefix_labels] ALTER COLUMN [title] varchar(4000)"); echo $modifyoutput; flush();
//124
modify_database("","ALTER TABLE [prefix_surveys] ADD [bounce_email] text"); echo $modifyoutput; flush();
//125
upgrade_token_tables125();
modify_database("","EXEC sp_rename 'prefix_users.move_user','superadmin'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_users] SET [superadmin]=1 where ([create_survey]=1 AND [create_user]=1 AND [delete_user]=1 AND [configurator]=1)"); echo $modifyoutput; flush();
//126
modify_database("","ALTER TABLE [prefix_questions] ADD [lid1] int NOT NULL DEFAULT '0'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_conditions] SET [method]='==' where ( [method] is null) or [method]=''"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='126' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
return true;
}
function upgrade_survey_tables117()
{
global $modifyoutput;
$surveyidquery = "SELECT sid FROM ".db_table_name('surveys')." WHERE active='Y' and datestamp='Y'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".db_table_name('survey_'.$sv[0])." ADD [startdate] datetime"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables118()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ALTER COLUMN [token] VARCHAR(36)"); echo $modifyoutput; flush();
}
}
function upgrade_token_tables125()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD COLUMN [emailstatus ] VARCHAR(300) DEFAULT 'OK'"); echo $modifyoutput; flush();
}
}
?>

View File

@@ -18,14 +18,190 @@
// For this there will be a settings table which holds the last time the database was upgraded
function db_upgrade($oldversion) {
global $modifyoutput;
if ($oldversion < 125) {
if ($oldversion < 127) {
modify_database("","create index answers_idx2 on prefix_answers (sortorder)"); echo $modifyoutput; flush();
modify_database("","create index assessments_idx2 on prefix_assessments (sid)"); echo $modifyoutput; flush();
modify_database("","create index assessments_idx on prefix_assessments (gid)"); echo $modifyoutput; flush();
modify_database("","create index conditions_idx2 on prefix_conditions (qid)"); echo $modifyoutput; flush();
modify_database("","create index conditions_idx3 on prefix_conditions (cqid)"); echo $modifyoutput; flush();
modify_database("","create index groups_idx2 on prefix_groups (sid)"); echo $modifyoutput; flush();
modify_database("","create index question_attributes_idx2 on prefix_question_attributes (qid)"); echo $modifyoutput; flush();
modify_database("","create index questions_idx2 on prefix_questions (sid)"); echo $modifyoutput; flush();
modify_database("","create index questions_idx3 on prefix_questions (gid)"); echo $modifyoutput; flush();
modify_database("","create index questions_idx4 on prefix_questions (type)"); echo $modifyoutput; flush();
modify_database("","create index quota_idx2 on prefix_quota (sid)"); echo $modifyoutput; flush();
modify_database("","create index saved_control_idx2 on prefix_saved_control (sid)"); echo $modifyoutput; flush();
modify_database("","create index user_in_groups_idx1 on prefix_user_in_groups (ugid, uid)"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='127' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 128) {
//128
upgrade_token_tables128();
modify_database("","update prefix_settings_global set stg_value='128' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 129) {
//129
modify_database("","ALTER TABLE prefix_surveys ADD startdate date"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys ADD usestartdate char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='129' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 130)
{
modify_database("","ALTER TABLE prefix_conditions ADD scenario integer NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("","UPDATE prefix_conditions SET scenario=1 where (scenario is null) or scenario=0"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='130' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 131)
{
modify_database("","ALTER TABLE prefix_surveys ADD publicstatistics char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='131' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 132)
{
modify_database("","ALTER TABLE prefix_surveys ADD publicgraphs char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='132' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 133)
{
modify_database("","ALTER TABLE prefix_users ADD one_time_pw bytea"); echo $modifyoutput; flush();
// Add new assessment setting
modify_database("","ALTER TABLE prefix_surveys ADD assessments char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
// add new assessment value fields to answers & labels
modify_database("","ALTER TABLE prefix_answers ADD assessment_value integer NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_labels ADD assessment_value integer NOT NULL default '0'"); echo $modifyoutput; flush();
// copy any valid codes from code field to assessment field
modify_database("","update [prefix_answers set assessment_value=CAST(code as integer)");// no output here is intended
modify_database("","update prefix_labels set assessment_value=CAST(code as integer)");// no output here is intended
// activate assessment where assesment rules exist
modify_database("","update prefix_surveys set assessments='Y' where sid in (SELECT sid FROM prefix_assessments group by sid)"); echo $modifyoutput; flush();
// add language field to assessment table
modify_database("","ALTER TABLE prefix_assessments ADD language character varying(20) NOT NULL default 'en'"); echo $modifyoutput; flush();
// update language field with default language of that particular survey
modify_database("","update prefix_assessments set language=(select language from prefix_surveys where sid=prefix_assessments.sid)"); echo $modifyoutput; flush();
// copy assessment link to message since from now on we will have HTML assignment messages
modify_database("","update prefix_assessments set message=cast(message as character) ||'<br /><a href=\"'||link||'\">'||link||'</a>'"); echo $modifyoutput; flush();
// drop the old link field
modify_database("","ALTER TABLE prefix_assessments DROP COLUMN link"); echo $modifyoutput; flush();
// change the primary index to include language
modify_database("","ALTER TABLE prefix_assessments DROP CONSTRAINT prefix_assessments_pkey"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_assessments ADD CONSTRAINT prefix_assessments_pkey PRIMARY KEY (id,language)"); echo $modifyoutput; flush();
// and fix missing translations for assessments
upgrade_survey_tables133();
// Add new fields to survey language settings
modify_database("","ALTER TABLE prefix_surveys_languagesettings ADD surveyls_url character varying(255)"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys_languagesettings ADD surveyls_endtext text"); echo $modifyoutput; flush();
// copy old URL fields ot language specific entries
modify_database("","update prefix_surveys_languagesettings set surveyls_url=(select url from prefix_surveys where sid=prefix_surveys_languagesettings.surveyls_survey_id)"); echo $modifyoutput; flush();
// drop old URL field
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN url"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='133' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 134)
{
modify_database("","ALTER TABLE prefix_surveys ADD usetokens char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys ADD attributedescriptions TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN attribute1"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN attribute2"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update prefix_settings_global set stg_value='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
{
modify_database("","ALTER TABLE prefix_question_attributes ALTER COLUMN value TYPE text"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='135' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 136)
{
modify_database("", "ALTER TABLE prefix_quota ADD autoload_url integer NOT NULL DEFAULT 0"); echo $modifyoutput; flush();
modify_database("", "CREATE TABLE prefix_quota_languagesettings (
quotals_id serial NOT NULL,
quotals_quota_id integer NOT NULL DEFAULT 0,
quotals_language character varying(45) NOT NULL DEFAULT 'en'::character varying,
quotals_name character varying(200),
quotals_message text NOT NULL,
quotals_url character varying(255),
quotals_urldescrip character varying(255));"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE ONLY prefix_quota_languagesettings
ADD CONSTRAINT prefix_quota_languagesettings_pkey PRIMARY KEY (quotals_id);"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE ONLY prefix_users ADD CONSTRAINT prefix_users_pkey PRIMARY KEY (uid)"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE ONLY prefix_users ADD CONSTRAINT prefix_user_name_key UNIQUE (users_name)"); echo $modifyoutput; flush();
modify_database("", "update prefix_settings_global set stg_value='136' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 137) //New date format specs
{
modify_database("", "ALTER TABLE prefix_surveys_languagesettings ADD surveyls_dateformat integer NOT NULL default 1"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE prefix_users ADD \"dateformat\" integer NOT NULL default 1"); echo $modifyoutput; flush();
modify_database("", "update prefix_surveys set startdate=null where usestartdate='N'"); echo $modifyoutput; flush();
modify_database("", "update prefix_surveys set expires=null where useexpiry='N'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE prefix_surveys DROP COLUMN usestartdate"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE prefix_surveys DROP COLUMN useexpiry"); echo $modifyoutput; flush();
modify_database("", "update prefix_settings_global set stg_value='137' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 138) //Modify quota field
{
modify_database("", "ALTER TABLE prefix_quota_members ALTER COLUMN code TYPE character varying(11)"); echo $modifyoutput; flush();
modify_database("", "UPDATE prefix_settings_global SET stg_value='138' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
return true;
}
function upgrade_token_tables128()
{
global $modifyoutput,$dbprefix;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv0." ADD remindersent character varying(17) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv0." ADD remindercount INTEGER DEFAULT 0"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables133()
{
global $modifyoutput;
$surveyidquery = "SELECT sid, additional_languages FROM ".db_table_name('surveys');
$surveyidresult = db_execute_num($surveyidquery);
while ( $sv = $surveyidresult->FetchRow() )
{
FixLanguageConsistency($sv['0'],$sv['1']);
}
}
function upgrade_token_tables134()
{
global $modifyoutput,$dbprefix;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD validfrom timestamp"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD validuntil timestamp"); echo $modifyoutput; flush();
}
}
}
?>

View File

@@ -1,402 +1,394 @@
<?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: integritycheck.php 4973 2008-06-01 14:07:01Z c_schmitz $
*/
include_once("login_check.php");
if($_SESSION['USER_RIGHT_CONFIGURATOR'] == 1)
{
// THIS FILE CHECKS THE CONSISTENCY OF THE DATABASE, IT LOOKS FOR
// STRAY QUESTIONS, ANSWERS, CONDITIONS OR GROUPS AND DELETES THEM
$ok=returnglobal('ok');
$integritycheck='';
if (!isset($ok) || $ok != "Y") // do the check, but don't delete anything
{
$integritycheck .= "<table><tr><td height='1'></td></tr></table>\n"
. "<table align='center' class='menu2columns' style='border: 1px solid #555555' "
. "cellpadding='1' cellspacing='0' width='450'>\n"
. "\t<tr>\n"
. "\t\t<td colspan='2' align='center'>\n"
. "\t\t\t<strong>".$clang->gT("Data Consistency Check")."<br /><font size='1'>".$clang->gT("If errors are showing up you might have to execute this script repeatedly.")."</font></strong>\n"
. "\t\t</td>\n"
. "\t</tr>\n"
. "\t<tr><td align='center'>"
. "<br />\n";
// Check conditions
// $query = "SELECT {$dbprefix}questions.sid, {$dbprefix}conditions.* "
// ."FROM {$dbprefix}conditions, {$dbprefix}questions "
// ."WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid "
// ."ORDER BY qid, cqid, cfieldname, value";
$query = "SELECT * FROM {$dbprefix}conditions ORDER BY cid";
$result = db_execute_assoc($query) or safe_die("Couldn't get list of conditions from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
$qquery="SELECT qid FROM {$dbprefix}questions WHERE qid='{$row['qid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check questions table for qids<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$cdelete[]=array("cid"=>$row['cid'], "reason"=>"No matching qid");}
$qquery = "SELECT qid FROM {$dbprefix}questions WHERE qid='{$row['cqid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check questions table for qids<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$cdelete[]=array("cid"=>$row['cid'], "reason"=>$clang->gT("No matching Cqid"));}
if ($row['cfieldname']) //Only do this if there actually is a "cfieldname"
{
list ($surveyid, $gid, $rest) = explode("X", $row['cfieldname']);
$qquery = "SELECT gid FROM {$dbprefix}groups WHERE gid=$gid";
$qresult = $connect->Execute($qquery) or safe_die ("Couldn't check conditional group matches<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if ($qcount < 1) {$cdelete[]=array("cid"=>$row['cid'], "reason"=>$clang->gT("No matching CFIELDNAME Group!")." ($gid) ({$row['cfieldname']})");}
}
elseif (!$row['cfieldname'])
{
$cdelete[]=array("cid"=>$row['cid'], "reason"=>$clang->gT("No \"CFIELDNAME\" field set!")." ({$row['cfieldname']})");
}
}
if (isset($cdelete) && $cdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following conditions should be deleted").":</strong><br /><font size='1'>\n";
foreach ($cdelete as $cd) {
$integritycheck .= "CID: {$cd['cid']} ".$clang->gT("because")." {$cd['reason']}<br />\n";
}
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All conditions meet consistency standards")."</strong><br />\n";
}
// Check question_attributes to delete
$query = "SELECT * FROM {$dbprefix}question_attributes ORDER BY qid";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
while($row = $result->FetchRow())
{
$aquery = "SELECT * FROM {$dbprefix}questions WHERE qid = {$row['qid']}";
$aresult = $connect->Execute($aquery) or safe_die($connect->ErrorMsg());
$qacount = $aresult->RecordCount();
if (!$qacount) {
$qadelete[]=array("qaid"=>$row['qaid'], "attribute"=>$row['attribute'], "reason"=>$clang->gT("No matching qid"));
}
} // while
if (isset($qadelete) && $qadelete) {
$integritycheck .= "<strong>".$clang->gT("The following question attributes should be deleted").":</strong><br /><font size='1'>\n";
foreach ($qadelete as $qad) {$integritycheck .= "QAID `{$qad['qaid']}` ATTRIBUTE `{$qad['attribute']}` ".$clang->gT("because")." `{$qad['reason']}`<br />\n";}
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All question_attributes meet consistency standards")."</strong><br />\n";
}
// Check assessments
$query = "SELECT * FROM {$dbprefix}assessments WHERE scope='T' ORDER BY sid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of assessments<br />$query<br />".$connect->ErrorMsg());
while($row = $result->FetchRow())
{
$aquery = "SELECT * FROM {$dbprefix}surveys WHERE sid = {$row['sid']}";
$aresult = db_execute_assoc($aquery) or safe_die("Oh dear - died in assessments surveys:".$aquery ."<br />".$connect->ErrorMsg());
$acount = $aresult->RecordCount();
if (!$acount) {
$assdelete[]=array("id"=>$row['id'], "assessment"=>$row['name'], "reason"=>$clang->gT("No matching survey"));
}
} // while
$query = "SELECT * FROM {$dbprefix}assessments WHERE scope='G' ORDER BY gid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of assessments<br />$query<br />".$connect->ErrorMsg());
while($row = $result->FetchRow())
{
$aquery = "SELECT * FROM {$dbprefix}groups WHERE gid = {$row['gid']}";
$aresult = $connect->Execute($aquery) or safe_die("Oh dear - died:".$aquery ."<br />".$connect->ErrorMsg());
$acount = $aresult->RecordCount();
if (!$acount) {
$asgdelete[]=array("id"=>$row['id'], "assessment"=>$row['name'], "reason"=>$clang->gT("No matching group"));
}
}
if (isset($assdelete) && $assdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following assessments should be deleted").":</strong><br /><font size='1'>\n";
foreach ($assdelete as $ass) {$integritycheck .= "ID `{$ass['id']}` ASSESSMENT `{$ass['assessment']}` ".$clang->gT("because")." `{$ass['reason']}`<br />\n";}
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All Survey (Total) assessments meet consistency standards")."</strong><br />\n";
}
if (isset($asgdelete) && $asgdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following assessments should be deleted").":</strong><br /><font size='1'>\n";
foreach ($asgdelete as $asg) {$integritycheck .= "ID `{$asg['id']}` ASSESSMENT `{$asg['assessment']}` ".$clang->gT("because")." `{$asg['reason']}`<br />\n";}
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All Group assessments meet consistency standards")."</strong><br />\n";
}
// Check answers
$query = "SELECT * FROM {$dbprefix}answers ORDER BY qid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of answers from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
//$integritycheck .= "Checking answer {$row['code']} to qid {$row['qid']}<br />\n";
$qquery="SELECT qid FROM {$dbprefix}questions WHERE qid='{$row['qid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check questions table for qids from answers<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {
$adelete[]=array("qid"=>$row['qid'], "code"=>$row['code'], "reason"=>$clang->gT("No matching question"));
}
//$integritycheck .= "<br />\n";
}
if (isset($adelete) && $adelete)
{
$integritycheck .= "<strong>".$clang->gT("The following answers should be deleted").":</strong><br /><font size='1'>\n";
foreach ($adelete as $ad) {$integritycheck .= "QID `{$ad['qid']}` CODE `{$ad['code']}` ".$clang->gT("because")." `{$ad['reason']}`<br />\n";}
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All answers meet consistency standards")."</strong><br />\n";
}
// Check surveys
$query = "SELECT * FROM {$dbprefix}surveys ORDER BY sid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of answers from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
$qquery="SELECT surveyls_survey_id FROM {$dbprefix}surveys_languagesettings WHERE surveyls_survey_id='{$row['sid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check languagesettings table for sids from surveys<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {
$sdelete[]=array("sid"=>$row['sid'], "reason"=>$clang->gT("Language specific settings missing"));
}
}
if (isset($sdelete) && $sdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following surveys should be deleted").":</strong><br /><font size='1'>\n";
foreach ($sdelete as $sd) {$integritycheck .= "SID `{$sd['sid']}` ".$clang->gT("because")." `{$sd['reason']}`<br />\n";}
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All survey settings meet consistency standards")."</strong><br />\n";
}
//check questions
$query = "SELECT * FROM {$dbprefix}questions ORDER BY sid, gid, qid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of questions from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
//Make sure group exists
$qquery="SELECT * FROM {$dbprefix}groups WHERE gid={$row['gid']}";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check groups table for gids from questions<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$qdelete[]=array("qid"=>$row['qid'], "reason"=>$clang->gT("No matching Group")." ({$row['gid']})");}
//Make sure survey exists
$qquery="SELECT * FROM {$dbprefix}surveys WHERE sid={$row['sid']}";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check surveys table for sids from questions<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {
if (!isset($qdelete) || !in_array($row['qid'], $qdelete)) {$qdelete[]=array("qid"=>$row['qid'], "reason"=>$clang->gT("No matching Survey!")." ({$row['sid']})");}
}
}
if (isset($qdelete) && $qdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following questions should be deleted").":</strong><br /><font size='1'>\n";
foreach ($qdelete as $qd) {$integritycheck .= "QID `{$qd['qid']}` ".$clang->gT("because")." `{$qd['reason']}`<br />\n";}
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All questions meet consistency standards")."</strong><br />\n";
}
//check groups
$query = "SELECT * FROM {$dbprefix}groups ORDER BY sid, gid";
$result=db_execute_assoc($query) or safe_die ("Couldn't get list of groups for checking<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
//make sure survey exists
$qquery = "SELECT * FROM {$dbprefix}groups WHERE sid={$row['sid']}";
$qresult=$connect->Execute($qquery) or safe_die("Couldn't check surveys table for gids from groups<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$gdelete[]=array($row['gid']);}
}
if (isset($gdelete) && $gdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following groups should be deleted").":</strong><br /><font size='1'>\n";
$integritycheck .= implode(", ", $gdelete);
$integritycheck .= "</font><br />\n";
}
else
{
$integritycheck .= "<strong>".$clang->gT("All groups meet consistency standards")."</strong><br />\n";
}
//NOW CHECK FOR STRAY SURVEY RESPONSE TABLES AND TOKENS TABLES
if (!isset($cdelete) && !isset($adelete) && !isset($qdelete) && !isset($gdelete) && !isset($asgdelete) && !isset($sdelete) && !isset($assdelete) && !isset($qadelete)) {
$integritycheck .= "<br />".$clang->gT("No database action required");
} else {
$integritycheck .= "<br />".$clang->gT("Should we proceed with the delete?")."<br />\n";
$integritycheck .= "<form action='{$_SERVER['PHP_SELF']}?action=checkintegrity' method='post'>\n";
if (isset($cdelete)) {
foreach ($cdelete as $cd) {
$integritycheck .= "<input type='hidden' name='cdelete[]' value='{$cd['cid']}' />\n";
}
}
if (isset($adelete)) {
foreach ($adelete as $ad) {
$integritycheck .= "<input type='hidden' name='adelete[]' value='{$ad['qid']}|{$ad['code']}' />\n";
}
}
if (isset($qdelete)) {
foreach($qdelete as $qd) {
$integritycheck .= "<input type='hidden' name='qdelete[]' value='{$qd['qid']}' />\n";
}
}
if (isset($gdelete)) {
foreach ($gdelete as $gd) {
$integritycheck .= "<input type='hidden' name='gdelete[]' value='{$gd['gid']}' />\n";
}
}
if (isset($qadelete)) {
foreach ($qadelete as $qad) {
$integritycheck .= "<input type='hidden' name='qadelete[]' value='{$qad['qaid']}'/>\n";
}
}
if (isset($assdelete)) {
foreach ($assdelete as $ass) {
$integritycheck .= "<input type='hidden' name='assdelete[]' value='{$ass['id']}'/>\n";
}
}
if (isset($asgdelete)) {
foreach ($asgdelete as $asg) {
$integritycheck .= "<input type='hidden' name='asgdelete[]' value='{$asg['id']}'/>\n";
}
}
if (isset($sdelete)) {
foreach ($sdelete as $asg) {
$integritycheck .= "<input type='hidden' name='sdelete[]' value='{$asg['sid']}'/>\n";
}
}
$integritycheck .= "<input type='hidden' name='ok' value='Y'>\n"
."<input type='submit' value='".$clang->gT("Yes - Delete Them!")."'>\n"
."</form>\n";
}
$integritycheck .= "<br /><br />\n"
."</td></tr></table>\n"
."<table><tr><td height='1'></td></tr></table>\n";
}
elseif ($ok == "Y")
{
$integritycheck .= "<table><tr><td height='1'></td></tr></table>\n"
. "<table align='center' style='border: 1px solid #555555' "
. "cellpadding='1' cellspacing='0' width='450'>\n"
. "\t<tr>\n"
. "\t\t<td colspan='2' align='center'>\n"
. "\t\t\t<strong>".$clang->gT("Data Consistency Check")."<br /><font size='1'>".$clang->gT("If errors are showing up you might have to execute this script repeatedly.")."</strong>\n"
. "\t\t</td>\n"
. "\t</tr>\n"
. "\t<tr><td align='center'>";
$cdelete=returnglobal('cdelete');
$adelete=returnglobal('adelete');
$qdelete=returnglobal('qdelete');
$gdelete=returnglobal('gdelete');
$assdelete=returnglobal('assdelete');
$asgdelete=returnglobal('asgdelete');
$qadelete=returnglobal('qadelete');
$sdelete=returnglobal('sdelete');
if (isset($sdelete)) {
$integritycheck .= $clang->gT("Deleting Surveys").":<br /><fontsize='1'>\n";
foreach ($sdelete as $ass) {
$integritycheck .= $clang->gT("Deleting Survey ID").":".$ass."<br />\n";
$sql = "DELETE FROM {$dbprefix}surveys WHERE sid=$ass";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($assdelete)) {
$integritycheck .= $clang->gT( "Deleting Assessments").":<br /><fontsize='1'>\n";
foreach ($assdelete as $ass) {
$integritycheck .= $clang->gT("Deleting ID").":".$ass."<br />\n";
$sql = "DELETE FROM {$dbprefix}assessments WHERE id=$ass";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($asgdelete)) {
$integritycheck .= $clang->gT("Deleting Assessments").":<br /><fontsize='1'>\n";
foreach ($asgdelete as $asg) {
$integritycheck .= $clang->gT("Deleting ID").":".$asg."<br />\n";
$sql = "DELETE FROM {$dbprefix}assessments WHERE id=$asg";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($qadelete)) {
$integritycheck .= $clang->gT("Deleting Question_Attributes").":<br /><fontsize='1'>\n";
foreach ($qadelete as $qad) {
$integritycheck .= "Deleting QAID:".$qad."<br />\n";
$sql = "DELETE FROM {$dbprefix}question_attributes WHERE qaid=$qad";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($cdelete)) {
$integritycheck .= $clang->gT("Deleting Conditions").":<br /><font size='1'>\n";
foreach ($cdelete as $cd) {
$integritycheck .= $clang->gT("Deleting cid").":".$cd."<br />\n";
$sql = "DELETE FROM {$dbprefix}conditions WHERE cid=$cd";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</font><br />\n";
}
if (isset($adelete)) {
$integritycheck .= $clang->gT("Deleting Answers").":<br /><font size='1'>\n";
foreach ($adelete as $ad) {
list($ad1, $ad2)=explode("|", $ad);
$integritycheck .= $clang->gT("Deleting answer with qid").":".$ad1." and code: ".$ad2."<br />\n";
$sql = "DELETE FROM {$dbprefix}answers WHERE qid=$ad1 AND code='$ad2'";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</font><br />\n";
}
if (isset($qdelete)) {
$integritycheck .= $clang->gT("Deleting Questions").":<br /><font size='1'>\n";
foreach ($qdelete as $qd) {
$integritycheck .= $clang->gT("Deleting qid").":".$qd."<br />\n";
$sql = "DELETE FROM {$dbprefix}questions WHERE qid=$qd";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</font><br />\n";
}
if (isset($gdelete)) {
$integritycheck .= $clang->gT("Deleting Groups").":<br /><font size='1'>\n";
foreach ($gdelete as $gd) {
$integritycheck .= $clang->gT("Deleting group id").":".$gd."<br />\n";
$sql = "DELETE FROM {$dbprefix}groups WHERE gid=$gd";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</font><br />\n";
}
$integritycheck .= $clang->gT("Check database again?")."<br />\n"
."<a href='{$_SERVER['PHP_SELF']}?action=checkintegrity'>".$clang->gT("Check Again")."</a><br />\n"
."</td></tr></table><br />\n";
}
$surveyid=false;
}
else
{
$action = "dbchecker";
include("access_denied.php");
include("admin.php");
}
?>
<?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: integritycheck.php 6976 2009-05-30 00:53:41Z c_schmitz $
*/
include_once("login_check.php");
if($_SESSION['USER_RIGHT_CONFIGURATOR'] == 1)
{
// THIS FILE CHECKS THE CONSISTENCY OF THE DATABASE, IT LOOKS FOR
// STRAY QUESTIONS, ANSWERS, CONDITIONS OR GROUPS AND DELETES THEM
$ok=returnglobal('ok');
$integritycheck='';
if (!isset($ok) || $ok != "Y") // do the check, but don't delete anything
{
$integritycheck .= "<div class='messagebox'>"
. "<div class='header'>".$clang->gT("Data Consistency Check")."<br /><span style='font-size:7pt;'>".$clang->gT("If errors are showing up you might have to execute this script repeatedly.")."</span></div>\n"
. "<ul>\n";
// Check conditions
// $query = "SELECT {$dbprefix}questions.sid, {$dbprefix}conditions.* "
// ."FROM {$dbprefix}conditions, {$dbprefix}questions "
// ."WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid "
// ."ORDER BY qid, scenario, cqid, cfieldname, value";
$query = "SELECT * FROM {$dbprefix}conditions ORDER BY cid";
$result = db_execute_assoc($query) or safe_die("Couldn't get list of conditions from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
$qquery="SELECT qid FROM {$dbprefix}questions WHERE qid='{$row['qid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check questions table for qids<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$cdelete[]=array("cid"=>$row['cid'], "reason"=>"No matching qid");}
$qquery = "SELECT qid FROM {$dbprefix}questions WHERE qid='{$row['cqid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check questions table for qids<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$cdelete[]=array("cid"=>$row['cid'], "reason"=>$clang->gT("No matching Cqid"));}
if ($row['cfieldname']) //Only do this if there actually is a "cfieldname"
{
list ($surveyid, $gid, $rest) = explode("X", $row['cfieldname']);
$qquery = "SELECT gid FROM {$dbprefix}groups WHERE gid=$gid";
$qresult = $connect->Execute($qquery) or safe_die ("Couldn't check conditional group matches<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if ($qcount < 1) {$cdelete[]=array("cid"=>$row['cid'], "reason"=>$clang->gT("No matching CFIELDNAME Group!")." ($gid) ({$row['cfieldname']})");}
}
elseif (!$row['cfieldname'])
{
$cdelete[]=array("cid"=>$row['cid'], "reason"=>$clang->gT("No \"CFIELDNAME\" field set!")." ({$row['cfieldname']})");
}
}
if (isset($cdelete) && $cdelete)
{
$integritycheck .= "<li>".$clang->gT("The following conditions should be deleted").":</li><br /><span style='font-size:7pt;'>\n";
foreach ($cdelete as $cd) {
$integritycheck .= "CID: {$cd['cid']} ".$clang->gT("because")." {$cd['reason']}<br />\n";
}
$integritycheck .= "<br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All conditions meet consistency standards")."</li>\n";
}
// Check question_attributes to delete
$query = "SELECT * FROM {$dbprefix}question_attributes ORDER BY qid";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
while($row = $result->FetchRow())
{
$aquery = "SELECT * FROM {$dbprefix}questions WHERE qid = {$row['qid']}";
$aresult = $connect->Execute($aquery) or safe_die($connect->ErrorMsg());
$qacount = $aresult->RecordCount();
if (!$qacount) {
$qadelete[]=array("qaid"=>$row['qaid'], "attribute"=>$row['attribute'], "reason"=>$clang->gT("No matching qid"));
}
} // while
if (isset($qadelete) && $qadelete) {
$integritycheck .= "<li>".$clang->gT("The following question attributes should be deleted").":</li><br /><span style='font-size:7pt;'>\n";
foreach ($qadelete as $qad) {$integritycheck .= "QAID `{$qad['qaid']}` ATTRIBUTE `{$qad['attribute']}` ".$clang->gT("because")." `{$qad['reason']}`<br />\n";}
$integritycheck .= "</span><br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All question attributes meet consistency standards")."</li>\n";
}
// Check assessments
$query = "SELECT * FROM {$dbprefix}assessments WHERE scope='T' ORDER BY sid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of assessments<br />$query<br />".$connect->ErrorMsg());
while($row = $result->FetchRow())
{
$aquery = "SELECT * FROM {$dbprefix}surveys WHERE sid = {$row['sid']}";
$aresult = db_execute_assoc($aquery) or safe_die("Oh dear - died in assessments surveys:".$aquery ."<br />".$connect->ErrorMsg());
$acount = $aresult->RecordCount();
if (!$acount) {
$assdelete[]=array("id"=>$row['id'], "assessment"=>$row['name'], "reason"=>$clang->gT("No matching survey"));
}
} // while
$query = "SELECT * FROM {$dbprefix}assessments WHERE scope='G' ORDER BY gid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of assessments<br />$query<br />".$connect->ErrorMsg());
while($row = $result->FetchRow())
{
$aquery = "SELECT * FROM {$dbprefix}groups WHERE gid = {$row['gid']}";
$aresult = $connect->Execute($aquery) or safe_die("Oh dear - died:".$aquery ."<br />".$connect->ErrorMsg());
$acount = $aresult->RecordCount();
if (!$acount) {
$asgdelete[]=array("id"=>$row['id'], "assessment"=>$row['name'], "reason"=>$clang->gT("No matching group"));
}
}
if (isset($assdelete) && $assdelete)
{
$integritycheck .= "<li>".$clang->gT("The following assessments should be deleted").":</li><span style='font-size:7pt;'>\n";
foreach ($assdelete as $ass) {$integritycheck .= "ID `{$ass['id']}` ASSESSMENT `{$ass['assessment']}` ".$clang->gT("because")." `{$ass['reason']}`<br />\n";}
$integritycheck .= "</span><br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All Survey (Total) assessments meet consistency standards")."</li>\n";
}
if (isset($asgdelete) && $asgdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following assessments should be deleted").":</strong><br /><span style='font-size:7pt;'>\n";
foreach ($asgdelete as $asg) {$integritycheck .= "ID `{$asg['id']}` ASSESSMENT `{$asg['assessment']}` ".$clang->gT("because")." `{$asg['reason']}`<br />\n";}
$integritycheck .= "</span><br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All Group assessments meet consistency standards")."</li>\n";
}
// Check answers
$query = "SELECT * FROM {$dbprefix}answers ORDER BY qid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of answers from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
//$integritycheck .= "Checking answer {$row['code']} to qid {$row['qid']}<br />\n";
$qquery="SELECT qid FROM {$dbprefix}questions WHERE qid='{$row['qid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check questions table for qids from answers<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {
$adelete[]=array("qid"=>$row['qid'], "code"=>$row['code'], "reason"=>$clang->gT("No matching question"));
}
//$integritycheck .= "<br />\n";
}
if (isset($adelete) && $adelete)
{
$integritycheck .= "<strong>".$clang->gT("The following answers should be deleted").":</strong><br /><span style='font-size:7pt;'>\n";
foreach ($adelete as $ad) {$integritycheck .= "QID `{$ad['qid']}` CODE `{$ad['code']}` ".$clang->gT("because")." `{$ad['reason']}`<br />\n";}
$integritycheck .= "</span><br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All answers meet consistency standards")."</li>\n";
}
// Check surveys
$query = "SELECT * FROM {$dbprefix}surveys ORDER BY sid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of answers from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
$qquery="SELECT surveyls_survey_id FROM {$dbprefix}surveys_languagesettings WHERE surveyls_survey_id='{$row['sid']}'";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check languagesettings table for sids from surveys<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {
$sdelete[]=array("sid"=>$row['sid'], "reason"=>$clang->gT("Language specific settings missing"));
}
}
if (isset($sdelete) && $sdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following surveys should be deleted").":</strong><br /><span style='font-size:7pt;'>\n";
foreach ($sdelete as $sd) {$integritycheck .= "SID `{$sd['sid']}` ".$clang->gT("because")." `{$sd['reason']}`<br />\n";}
$integritycheck .= "</span><br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All survey settings meet consistency standards")."</li>\n";
}
//check questions
$query = "SELECT * FROM {$dbprefix}questions ORDER BY sid, gid, qid";
$result = db_execute_assoc($query) or safe_die ("Couldn't get list of questions from database<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
//Make sure group exists
$qquery="SELECT * FROM {$dbprefix}groups WHERE gid={$row['gid']}";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check groups table for gids from questions<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$qdelete[]=array("qid"=>$row['qid'], "reason"=>$clang->gT("No matching group")." ({$row['gid']})");}
//Make sure survey exists
$qquery="SELECT * FROM {$dbprefix}surveys WHERE sid={$row['sid']}";
$qresult=$connect->Execute($qquery) or safe_die ("Couldn't check surveys table for sids from questions<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {
if (!isset($qdelete) || !in_array($row['qid'], $qdelete)) {$qdelete[]=array("qid"=>$row['qid'], "reason"=>$clang->gT("No matching survey")." ({$row['sid']})");}
}
}
if (isset($qdelete) && $qdelete)
{
$integritycheck .= "<strong>".$clang->gT("The following questions should be deleted").":</strong><br /><span style='font-size:7pt;'>\n";
foreach ($qdelete as $qd) {$integritycheck .= "QID `{$qd['qid']}` ".$clang->gT("because")." `{$qd['reason']}`<br />\n";}
$integritycheck .= "</span><br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All questions meet consistency standards")."</li>\n";
}
//check groups
$query = "SELECT * FROM {$dbprefix}groups ORDER BY sid, gid";
$result=db_execute_assoc($query) or safe_die ("Couldn't get list of groups for checking<br />$query<br />".$connect->ErrorMsg());
while ($row=$result->FetchRow())
{
//make sure survey exists
$qquery = "SELECT * FROM {$dbprefix}groups WHERE sid={$row['sid']}";
$qresult=$connect->Execute($qquery) or safe_die("Couldn't check surveys table for gids from groups<br />$qquery<br />".$connect->ErrorMsg());
$qcount=$qresult->RecordCount();
if (!$qcount) {$gdelete[]=array($row['gid']);}
}
if (isset($gdelete) && $gdelete)
{
$integritycheck .= "<li>".$clang->gT("The following groups should be deleted").":</li><span style='font-size:7pt;'>\n";
$integritycheck .= implode(", ", $gdelete);
$integritycheck .= "</span><br />\n";
}
else
{
$integritycheck .= "<li>".$clang->gT("All groups meet consistency standards")."</li>\n";
}
$integritycheck .='</ul>' ;
//NOW CHECK FOR STRAY SURVEY RESPONSE TABLES AND TOKENS TABLES
if (!isset($cdelete) && !isset($adelete) && !isset($qdelete) && !isset($gdelete) && !isset($asgdelete) && !isset($sdelete) && !isset($assdelete) && !isset($qadelete)) {
$integritycheck .= "<br />".$clang->gT("No database action required");
} else {
$integritycheck .= "<br />".$clang->gT("Should we proceed with the delete?")."<br />\n";
$integritycheck .= "<form action='{$_SERVER['PHP_SELF']}?action=checkintegrity' method='post'>\n";
if (isset($cdelete)) {
foreach ($cdelete as $cd) {
$integritycheck .= "<input type='hidden' name='cdelete[]' value='{$cd['cid']}' />\n";
}
}
if (isset($adelete)) {
foreach ($adelete as $ad) {
$integritycheck .= "<input type='hidden' name='adelete[]' value='{$ad['qid']}|{$ad['code']}' />\n";
}
}
if (isset($qdelete)) {
foreach($qdelete as $qd) {
$integritycheck .= "<input type='hidden' name='qdelete[]' value='{$qd['qid']}' />\n";
}
}
if (isset($gdelete)) {
foreach ($gdelete as $gd) {
$integritycheck .= "<input type='hidden' name='gdelete[]' value='{$gd['gid']}' />\n";
}
}
if (isset($qadelete)) {
foreach ($qadelete as $qad) {
$integritycheck .= "<input type='hidden' name='qadelete[]' value='{$qad['qaid']}'/>\n";
}
}
if (isset($assdelete)) {
foreach ($assdelete as $ass) {
$integritycheck .= "<input type='hidden' name='assdelete[]' value='{$ass['id']}'/>\n";
}
}
if (isset($asgdelete)) {
foreach ($asgdelete as $asg) {
$integritycheck .= "<input type='hidden' name='asgdelete[]' value='{$asg['id']}'/>\n";
}
}
if (isset($sdelete)) {
foreach ($sdelete as $asg) {
$integritycheck .= "<input type='hidden' name='sdelete[]' value='{$asg['sid']}'/>\n";
}
}
$integritycheck .= "<input type='hidden' name='ok' value='Y'>\n"
."<input type='submit' value='".$clang->gT("Yes - Delete Them!")."'>\n"
."</form>\n";
}
$integritycheck .= "</div><br />\n";
}
elseif ($ok == "Y")
{
$integritycheck .= "<table><tr><td height='1'></td></tr></table>\n"
. "<table align='center' style='border: 1px solid #555555' "
. "cellpadding='1' cellspacing='0' width='450'>\n"
. "\t<tr>\n"
. "\t\t<td colspan='2' align='center'>\n"
. "\t\t\t<strong>".$clang->gT("Data Consistency Check")."<br /><span style='font-size:7pt;'>".$clang->gT("If errors are showing up you might have to execute this script repeatedly.")."</strong>\n"
. "\t\t</td>\n"
. "\t</tr>\n"
. "\t<tr><td align='center'>";
$cdelete=returnglobal('cdelete');
$adelete=returnglobal('adelete');
$qdelete=returnglobal('qdelete');
$gdelete=returnglobal('gdelete');
$assdelete=returnglobal('assdelete');
$asgdelete=returnglobal('asgdelete');
$qadelete=returnglobal('qadelete');
$sdelete=returnglobal('sdelete');
if (isset($sdelete)) {
$integritycheck .= $clang->gT("Deleting Surveys").":<br /><spanstyle='font-size:7pt;'>\n";
foreach ($sdelete as $ass) {
$integritycheck .= $clang->gT("Deleting Survey ID").":".$ass."<br />\n";
$sql = "DELETE FROM {$dbprefix}surveys WHERE sid=$ass";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($assdelete)) {
$integritycheck .= $clang->gT( "Deleting Assessments").":<br /><spanstyle='font-size:7pt;'>\n";
foreach ($assdelete as $ass) {
$integritycheck .= $clang->gT("Deleting ID").":".$ass."<br />\n";
$sql = "DELETE FROM {$dbprefix}assessments WHERE id=$ass";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($asgdelete)) {
$integritycheck .= $clang->gT("Deleting Assessments").":<br /><spanstyle='font-size:7pt;'>\n";
foreach ($asgdelete as $asg) {
$integritycheck .= $clang->gT("Deleting ID").":".$asg."<br />\n";
$sql = "DELETE FROM {$dbprefix}assessments WHERE id=$asg";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($qadelete)) {
$integritycheck .= $clang->gT("Deleting Question_Attributes").":<br /><spanstyle='font-size:7pt;'>\n";
foreach ($qadelete as $qad) {
$integritycheck .= "Deleting QAID:".$qad."<br />\n";
$sql = "DELETE FROM {$dbprefix}question_attributes WHERE qaid=$qad";
$result = $connect->Execute($sql) or safe_die ("Couldn't delete ($sql)<br />".$connect->ErrorMsg());
}
}
if (isset($cdelete)) {
$integritycheck .= $clang->gT("Deleting Conditions").":<br /><span style='font-size:7pt;'>\n";
foreach ($cdelete as $cd) {
$integritycheck .= $clang->gT("Deleting cid").":".$cd."<br />\n";
$sql = "DELETE FROM {$dbprefix}conditions WHERE cid=$cd";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</span><br />\n";
}
if (isset($adelete)) {
$integritycheck .= $clang->gT("Deleting Answers").":<br /><span style='font-size:7pt;'>\n";
foreach ($adelete as $ad) {
list($ad1, $ad2)=explode("|", $ad);
$integritycheck .= $clang->gT("Deleting answer with qid").":".$ad1." and code: ".$ad2."<br />\n";
$sql = "DELETE FROM {$dbprefix}answers WHERE qid=$ad1 AND code='$ad2'";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</span><br />\n";
}
if (isset($qdelete)) {
$integritycheck .= $clang->gT("Deleting Questions").":<br /><span style='font-size:7pt;'>\n";
foreach ($qdelete as $qd) {
$integritycheck .= $clang->gT("Deleting qid").":".$qd."<br />\n";
$sql = "DELETE FROM {$dbprefix}questions WHERE qid=$qd";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</span><br />\n";
}
if (isset($gdelete)) {
$integritycheck .= $clang->gT("Deleting Groups").":<br /><span style='font-size:7pt;'>\n";
foreach ($gdelete as $gd) {
$integritycheck .= $clang->gT("Deleting group id").":".$gd."<br />\n";
$sql = "DELETE FROM {$dbprefix}groups WHERE gid=$gd";
$result=$connect->Execute($sql) or safe_die ("Couldn't Delete ($sql)<br />".$connect->ErrorMsg());
}
$integritycheck .= "</span><br />\n";
}
$integritycheck .= $clang->gT("Check database again?")."<br />\n"
."<a href='{$_SERVER['PHP_SELF']}?action=checkintegrity'>".$clang->gT("Check Again")."</a><br />\n"
."</td></tr></table><br />\n";
}
$surveyid=false;
}
else
{
$action = "dbchecker";
include("access_denied.php");
include("admin.php");
}
?>

View File

@@ -0,0 +1,69 @@
<?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: iterate_survey.php 6380 2009-02-16 13:30:17Z c_schmitz $
*/
/*
* Set completed answers to the incomplete state and reset the tokens to 'not used' so that
* the survey can be published again to the same set of participants.
* Partipants will see their previous answers and may change them.
*/
include_once('login_check.php');
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($subaction))
{ // subaction is not set, then display instructions
$iteratesurveyoutput = browsemenubar($clang->gT('Iterate survey'));
$iteratesurveyoutput .= "<br />\n";
$iteratesurveyoutput .= "<div class='header'>".$clang->gT("Iterate survey")."</div>\n";
$iteratesurveyoutput .= "<h3>".$clang->gT("Important instructions")."</h3>"
. "<p style='width:80%;'>\n"
. "<div align='center'>".$clang->gT("Click on the following button if you want to").":<br /></div>\n"
. "<ol style='width:500px;margin:0 auto; font-size:8pt;'>"
. "<li>".$clang->gT("Delete all incomplete answers that correspond to a token for which a completed answers is already recorded")."</li>"
. "<li>".$clang->gT("Reset the completed answers to the incomplete state")."</li>"
. "<li>".$clang->gT("Reset all your tokens to the 'not used' state")."</li>"
. "</ol><br />\n"
. "<input type='button' onclick=\"if( confirm('".$clang->gT("Are you really sure you want to *delete* some incomplete answers and reset the completed state of both answers and tokens?","js")."')){".get2post("$scriptname?action=iteratesurvey&amp;sid=$surveyid&amp;subaction=unfinalizeanswers")."}\" value='".$clang->gT("Reset answers and token completed state")."'>"
. "<table><tr><td>";
}
if ($subaction=='unfinalizeanswers')
{
$iteratesurveyoutput = browsemenubar($clang->gT('Iterate survey'));
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$surveytable = db_table_name("survey_$surveyid");
// First delete incomplete answers that correspond to a token for which a completed answers is already recorded
// subquery in delete or update are tricky things when using the same table for delete and Select
// see http://www.developpez.net/forums/d494961/bases-donnees/mysql/requetes/cant-specify-target-in-from-clause/
$updateqr = "DELETE from $surveytable WHERE submitdate IS NULL AND token in (SELECT * FROM ( SELECT answ2.token from $surveytable AS answ2 WHERE answ2.submitdate IS NOT NULL) tmp );\n";
// $updateqr = "DELETE from $surveytable WHERE submitdate IS NULL AND token in (SELECT b.token from $surveytable AS b WHERE b.submitdate IS NOT NULL);\n";
//error_log("TIBO query = $updateqr");
$updateres = $connect->Execute($updateqr) or safe_die("Delete incomplete answers with duplicate tokens failed:<br />\n" . $connect->ErrorMsg() . "<br />$updateqr");
// Then set all remaining answers to incomplete state
$updateqr = "UPDATE $surveytable SET submitdate=NULL;\n";
$updateres = $connect->Execute($updateqr) or safe_die("UnFinilize answers failed:<br />\n" . $connect->ErrorMsg() . "<br />$updateqr");
// Finally, reset the token completed and sent status
$updateqr="UPDATE ".db_table_name("tokens_$surveyid")." SET sent='N', remindersent='N', remindercount=0, completed='N'";
$updateres=$connect->Execute($updateqr) or safe_die ("Couldn't reset token completed state<br />$updateqr<br />".$connect->ErrorMsg());
$iteratesurveyoutput .= "<br />\n";
$iteratesurveyoutput .= "<div class='header'>".$clang->gT("Iterate survey")."</div>\n";
$iteratesurveyoutput .= "<p style='width:100%;'>\n"
. "<font class='successtitle'>".$clang->gT("Success")."</font><br />\n"
. $clang->gT("Answers and tokens have been re-opened.")."<br />\n"
. "</p>\n"
. "<table><tr><td>";
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,71 +1,80 @@
<?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: listcolumn.php 4973 2008-06-01 14:07:01Z c_schmitz $
*/
include_once("login_check.php");
sendcacheheaders();
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($column)) {$column=returnglobal('column');}
if (!isset($order)) {$order=returnglobal('order');}
if (!isset($sql)) {$sql=returnglobal('sql');}
if (!$surveyid)
{
//NOSID
exit;
}
if (!$column)
{
//NOCOLUMN
exit;
}
if ($connect->databaseType == 'odbc_mssql')
{ $query = "SELECT id, ".db_quote_id($column)." FROM {$dbprefix}survey_$surveyid WHERE (".db_quote_id($column)." NOT LIKE '')"; }
else
{ $query = "SELECT id, ".db_quote_id($column)." FROM {$dbprefix}survey_$surveyid WHERE (".db_quote_id($column)." != '')"; }
if ($sql && $sql != "NULL")
{
$query .= " AND ".auto_unescape(urldecode($sql));
}
if (incompleteAnsFilterstate() === true) {$query .= " AND submitdate is not null";}
if ($order == "alpha")
{
$query .= " ORDER BY ".db_quote_id($column);
}
$result=db_execute_assoc($query) or safe_die("Error with query: ".$query."<br />".$connect->ErrorMsg());
$listcolumnoutput= "<table width='98%' class='statisticstable' border='1' cellpadding='2' cellspacing='0'>\n";
$listcolumnoutput.= "<tr><td><input type='image' src='$imagefiles/downarrow.png' align='middle' onclick=\"window.open('admin.php?action=listcolumn&amp;sid=$surveyid&amp;column=$column&amp;order=id', '_self')\" /></td>\n";
$listcolumnoutput.= "<td valign='top'><input type='image' align='right' src='$imagefiles/close.gif' onclick='window.close()' />";
if ($connect->databaseType != 'odbc_mssql')
{ $listcolumnoutput.= "<input type='image' src='$imagefiles/downarrow.png' align='left' onclick=\"window.open('admin.php?action=listcolumn&amp;sid=$surveyid&amp;column=$column&amp;order=alpha', '_self')\" />"; }
$listcolumnoutput.= "</td></tr>\n";
while ($row=$result->FetchRow())
{
$listcolumnoutput.= "<tr><td valign='top' align='center' >"
. "<a href='$scriptname?action=browse&amp;sid=$surveyid&amp;subaction=id&amp;id=".$row['id']."' target='home'>"
. $row['id']."</a></td>"
. "<td valign='top'>".$row[$column]."</td></tr>\n";
}
$listcolumnoutput.= "</table>\n";
?>
<?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: listcolumn.php 7212 2009-07-03 07:32:05Z c_schmitz $
*/
include_once("login_check.php");
sendcacheheaders();
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($column)) {$column=returnglobal('column');}
if (!isset($order)) {$order=returnglobal('order');}
if (!isset($sql)) {$sql=returnglobal('sql');}
if (!$surveyid)
{
//NOSID
exit;
}
if (!$column)
{
//NOCOLUMN
exit;
}
if ($connect->databaseType == 'odbc_mssql' || $connect->databaseType == 'odbtp' || $connect->databaseType == 'mssql_n')
{ $query = "SELECT id, ".db_quote_id($column)." FROM {$dbprefix}survey_$surveyid WHERE (".db_quote_id($column)." NOT LIKE '')"; }
else
{ $query = "SELECT id, ".db_quote_id($column)." FROM {$dbprefix}survey_$surveyid WHERE (".db_quote_id($column)." != '')"; }
if ($sql && $sql != "NULL")
{
$query .= " AND ".auto_unescape(urldecode($sql));
}
switch (incompleteAnsFilterstate()) {
case 'inc':
//Inclomplete answers only
$query .= ' AND submitdate is null ';
break;
case 'filter':
//Inclomplete answers only
$query .= ' AND submitdate is not null ';
break;
}
if ($order == "alpha")
{
$query .= " ORDER BY ".db_quote_id($column);
}
$result=db_execute_assoc($query) or safe_die("Error with query: ".$query."<br />".$connect->ErrorMsg());
$listcolumnoutput= "<table width='98%' class='statisticstable' border='1' cellpadding='2' cellspacing='0'>\n";
$listcolumnoutput.= "<thead><tr><th><input type='image' src='$imagefiles/downarrow.png' align='middle' onclick=\"window.open('admin.php?action=listcolumn&amp;sid=$surveyid&amp;column=$column&amp;order=id', '_self')\" /></th>\n";
$listcolumnoutput.= "<th valign='top'><input type='image' align='right' src='$imagefiles/close.gif' onclick='window.close()' />";
if ($connect->databaseType != 'odbc_mssql' && $connect->databaseType != 'odbtp' && $connect->databaseType != 'mssql_n')
{ $listcolumnoutput.= "<input type='image' src='$imagefiles/downarrow.png' align='left' onclick=\"window.open('admin.php?action=listcolumn&amp;sid=$surveyid&amp;column=$column&amp;order=alpha', '_self')\" />"; }
$listcolumnoutput.= "</th></tr>\n";
while ($row=$result->FetchRow())
{
$listcolumnoutput.= "<tr><td valign='top' align='center' >"
. "<a href='$scriptname?action=browse&amp;sid=$surveyid&amp;subaction=id&amp;id=".$row['id']."' target='home'>"
. $row['id']."</a></td>"
. "<td valign='top'>".htmlspecialchars($row[$column])."</td></tr>\n";
}
$listcolumnoutput.= "</table>\n";
?>

View File

@@ -1,146 +1,248 @@
<?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: login_check.php 5039 2008-06-10 19:12:04Z c_schmitz $
*/
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
if (!isset($action)) {$action=returnglobal('action');}
// check data for login
if( isset($_POST['user']) && isset($_POST['password']) ||
($action == "forgotpass") || ($action == "login") ||
($action == "logout") ||
($useWebserverAuth === true && !isset($_SESSION['loginID'])) ) // added by Dennis
{
include("usercontrol.php");
}
// login form
if(!isset($_SESSION['loginID']) && $action != "forgotpass" && ($action != "logout" || ($action == "logout" && !isset($_SESSION['loginID'])))) // && $action != "login") // added by Dennis
{
if($action == "forgotpassword")
{
$loginsummary = "<form name='forgot' id='forgot' method='post' action='$rooturl/admin/admin.php' ><br /><strong>".$clang->gT("You have to enter user name and email.")."</strong><br /> <br />
<table>
<tr>
<td><p>".$clang->gT("Username")."</p></td>
<td><input name='user' type='text' id='user' size='40' maxlength='40' value='' /></td>
</tr>
<tr>
<td><p>".$clang->gT("Email")."</p></td>
<td><input name='email' id='email' type='text' size='40' maxlength='40' value='' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='hidden' name='action' value='forgotpass' />
<input class='action' type='submit' value='".$clang->gT("Check Data")."' /><br />&nbsp;\n</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><a href='$scriptname'>".$clang->gT("Main Admin Screen")."</a></td>
</tr>
</table>
</form>";
}
elseif (!isset($loginsummary))
{ // could be at login or after logout
$refererargs=''; // If this is a direct access to admin.php, no args are given
// If we are called from a link with action and other args set, get them
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'])
{
$refererargs = html_escape($_SERVER['QUERY_STRING']);
}
$hidden_loginlang = '';
if (isset($_POST['lang']) && $_POST['lang'])
{
$hidden_loginlang = "<input type='hidden' name='loginlang' value='".sanitize_languagecode($_POST['lang'])."' />";
}
if (!isset($logoutsummary))
{
$loginsummary = "<form name='login' id='login' method='post' action='$rooturl/admin/admin.php' ><br /><strong>".$clang->gT("You have to login first.")."</strong><br /> <br />";
}
else
{
$loginsummary = "<form name='login' id='login' method='post' action='$rooturl/admin/admin.php' ><br /><strong>".$logoutsummary."</strong><br /> <br />";
}
$loginsummary .= "
<table>
<tr>
<td>".$clang->gT("Username")."</td>
<td><input name='user' type='text' id='user' size='40' maxlength='40' value='' /></td>
</tr>
<tr>
<td>".$clang->gT("Password")."</td>
<td><input name='password' id='password' type='password' size='40' maxlength='40' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align='center'><input type='hidden' name='action' value='login' />
<input type='hidden' name='refererargs' value='".$refererargs."' />
$hidden_loginlang
<input class='action' type='submit' value='".$clang->gT("Login")."' /><br />&nbsp;\n</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><a href='$scriptname?action=forgotpassword'>".$clang->gT("Forgot Your Password?")."</a><br />&nbsp;\n</td>
</tr>
</table>
</form>";
// Language selection
$loginsummary .= "\t<form name='language' id='language' method='post' action='$rooturl/admin/admin.php' >"
. "\t<table><tr>\n"
. "\t\t<td align='center' >\n"
. "\t\t\t".$clang->gT("Current Language").":\n"
. "\t\t</td><td>\n"
. "\t\t\t<select name='lang' onchange='form.submit()'>\n";
foreach (getlanguagedata() as $langkey=>$languagekind)
{
$loginsummary .= "\t\t\t\t<option value='$langkey'";
if (isset($_SESSION['adminlang']) && $langkey == $_SESSION['adminlang']) {$loginsummary .= " selected='selected'";}
// in case it is a logout, session has already been killed
if (!isset($_SESSION['adminlang']) && $langkey == $clang->getlangcode() ){$loginsummary .= " selected='selected'";}
$loginsummary .= ">".$languagekind['description']." - ".$languagekind['nativedescription']."</option>\n";
}
$loginsummary .= "\t\t\t</select>\n"
. "\t\t\t<input type='hidden' name='action' value='changelang' />\n"
. "\t\t</td>\n"
. "\t</tr>\n"
. "</table>"
. "</form><br />";
}
}
if (isset($loginsummary)) {
$adminoutput.= "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"
."\t<tr>\n"
."\t\t<td valign='top' align='center' bgcolor='#F8F8FF'>\n";
if(isset($_SESSION['loginID']))
{
$adminoutput.= showadminmenu();
}
$adminoutput.= $loginsummary;
$adminoutput.= "\t\t</td>\n";
$adminoutput.= "\t</tr>\n";
$adminoutput.= "</table>\n";
}
?>
<?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: login_check.php 6871 2009-05-18 14:53:08Z c_schmitz $
*/
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
if (!isset($action)) {$action=returnglobal('action');}
/*
* New feature since version 1.81: One time passwords
* The user can call the limesurvey login at /limesurvey/admin and pass username and
* a one time password which was previously written into the users table (column one_time_pw) by
* an external application.
* Furthermore there is a setting in config-defaults which has to be turned on (default = off)
* to enable the usage of one time passwords.
*/
//check if data was passed by URL
if(isset($_GET['user']) && isset($_GET['onepass']))
{
//take care of passed data
$user = sanitize_user($_GET['user']);
$pw = sanitize_paranoid_string(md5($_GET['onepass']));
//check if setting $use_one_time_passwords exists in config file
if(isset($use_one_time_passwords))
{
//$use_one_time_passwords switched OFF but data was passed by URL: Show error message
if($use_one_time_passwords === false)
{
//create an error message
$loginsummary = "<br />".$clang->gT("Data for username and one time password was received but the usage of one time passwords is disabled at your configuration settings. Please add the following line to config.php to enable one time passwords: ")."<br />";
$loginsummary .= '<br /><em>$use_one_time_passwords = true;</em><br />';
$loginsummary .= "<br /><br /><a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
//Data was passed, using one time passwords is enabled
else
{
//check if user exists in DB
$query = "SELECT uid, users_name, password, one_time_pw FROM ".db_table_name('users')." WHERE users_name=".$connect->qstr($user);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; //Checked
$result = $connect->SelectLimit($query, 1) or safe_die ($query."<br />".$connect->ErrorMsg());
if(!$result)
{
echo "<br />".$connect->ErrorMsg();
}
if ($result->RecordCount() < 1)
{
// wrong or unknown username
$loginsummary = sprintf($clang->gT("No one-time password found for user %s"),htmlspecialchars($user))."<br />";
session_regenerate_id();
}
else
{
//get one time pw from db
$srow = $result->FetchRow();
$otpw = $srow['one_time_pw'];
//check if passed password and one time password from database DON'T match
if($pw != $otpw)
{
//no match -> warning
$loginsummary = "<br />".sprintf($clang->gT("Passed one time password doesn't match one time password for user %s")," <em>".htmlspecialchars($user)."</em>")."<br />";
$loginsummary .= "<br /><br /><a href='$scriptname'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
//both passwords match
else
{
//delete one time password in database
$uquery = "UPDATE ".db_table_name('users')."
SET one_time_pw=''
WHERE users_name='".db_quote($user)."'";
$uresult = $connect->Execute($uquery);
//data necessary for following functions
$_SESSION['user'] = $srow['users_name'];
$_SESSION['checksessionpost'] = randomkey(10);
$_SESSION['loginID'] = $srow['uid'];
GetSessionUserRights($_SESSION['loginID']);
// Check if the user has changed his default password
if (strtolower($srow['password'])=='password')
{
$_SESSION['pw_notify']=true;
}
else
{
$_SESSION['pw_notify']=false;
}
//delete passed information
unset($_GET['user']);
unset($_GET['onepass']);
} //else -> passwords match
} //else -> password found
} //else -> one time passwords enabled
} //else -> one time passwords set
} //else -> data was passed by URL
// check data for login
if( isset($_POST['user']) && isset($_POST['password']) ||
($action == "forgotpass") || ($action == "login") ||
($action == "logout") ||
($useWebserverAuth === true && !isset($_SESSION['loginID'])) ) // added by Dennis
{
include("usercontrol.php");
}
// login form
if(!isset($_SESSION['loginID']) && $action != "forgotpass" && ($action != "logout" || ($action == "logout" && !isset($_SESSION['loginID'])))) // && $action != "login") // added by Dennis
{
if($action == "forgotpassword")
{
$loginsummary = '
<form name="forgot" id="forgot" method="post" action="'.$rooturl.'/admin/admin.php" >
<p><strong>'.$clang->gT('You have to enter user name and email.').'</strong></p>
<table>
<tbody>
<tr>
<td><label for="user">'.$clang->gT('Username').'</label></td>
<td><input name="user" id="user" type="text" size="40" maxlength="40" value="" /></td>
</tr>
<tr>
<td><label for="email">'.$clang->gT('Email').'</label></td>
<td><input name="email" id="email" type="text" size="40" maxlength="40" value="" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="hidden" name="action" value="forgotpass" />
<input class="action" type="submit" value="'.$clang->gT('Check Data').'" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><a href="'.$scriptname.'">'.$clang->gT('Main Admin Screen').'</a></td>
</tr>
</table>
</form>
';
}
elseif (!isset($loginsummary))
{ // could be at login or after logout
$refererargs=''; // If this is a direct access to admin.php, no args are given
// If we are called from a link with action and other args set, get them
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'])
{
$refererargs = html_escape($_SERVER['QUERY_STRING']);
}
$hidden_loginlang = "<input type='hidden' name='loginlang' id='loginlang' value='".$defaultlang."' />";
if (!isset($logoutsummary))
{
$loginsummary = "<form name='login' id='login' method='post' action='$rooturl/admin/admin.php' ><br /><strong>".$clang->gT("You have to login first.")."</strong><br /> <br />";
}
else
{
$loginsummary = "<form name='login' id='login' method='post' action='$rooturl/admin/admin.php' ><br /><strong>".$logoutsummary."</strong><br /> <br />";
}
$loginsummary .= "
<table>
<tr>
<td>".$clang->gT("Username")."</td>
<td><input name='user' id='user' type='text' size='40' maxlength='40' value='' /></td>
</tr>
<tr>
<td>".$clang->gT("Password")."</td>
<td><input name='password' id='password' type='password' size='40' maxlength='40' /></td>
</tr>
<tr>
<td>".$clang->gT("Language")."</td>
<td>
<select name='lang' style='width:216px;' onchange='loginlang.value=this.value;'>\n";
$loginsummary .='<option value="default">'.$clang->gT('Default').'</option>';
foreach (getlanguagedata() as $langkey=>$languagekind)
{
$loginsummary .= "\t\t\t\t<option value='$langkey'>".$languagekind['description']." - ".$languagekind['nativedescription']."</option>\n";
}
$loginsummary .= "\t\t\t</select>\n"
. "</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align='center'><input type='hidden' name='action' value='login' />
<input type='hidden' name='refererargs' value='".$refererargs."' />
$hidden_loginlang
<input class='action' type='submit' value='".$clang->gT("Login")."' /><br />&nbsp;\n</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align='center'><a href='$scriptname?action=forgotpassword'>".$clang->gT("Forgot Your Password?")."</a><br />&nbsp;\n</td>
</tr>
</table>
</form><br />";
$loginsummary .= " <script type='text/javascript'>\n";
$loginsummary .= " document.getElementById('user').focus();\n";
$loginsummary .= " </script>\n";
}
}
if (isset($loginsummary))
{
$adminoutput.= "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"
."\t<tr>\n"
."\t\t<td valign='top' align='center' bgcolor='#F8F8FF'>\n";
if(isset($_SESSION['loginID']))
{
$adminoutput.= showadminmenu();
}
$adminoutput.= $loginsummary;
$adminoutput.= "\t\t</td>\n";
$adminoutput.= "\t</tr>\n";
$adminoutput.= "</table>\n";
}
?>

View File

@@ -0,0 +1,88 @@
<?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: $
*/
if (!isset($dbprefix) || isset($_REQUEST['dbprefix'])) {die("Cannot run this script directly");}
if (!isset($action)) {$action=returnglobal('action');}
//
// phpCAS simple client
//
if(!isset($_SESSION['CASauthenticated']) || (isset($_SESSION['CASauthenticated']) && $_SESSION['CASauthenticated']==FALSE) || isset($_REQUEST['action']))
{
// import phpCAS lib
include_once('classes/phpCAS/CAS.php');
phpCAS::setDebug();
// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, $casAuthServer, $casAuthPort, $casAuthUri, false);
// no SSL validation for the CAS server
phpCAS::setNoCasServerValidation();
//if($action=='logout')
if (isset($_REQUEST['action']) && $_REQUEST['action']=='logout')
{
session_destroy();
session_write_close();
phpCAS::logout();
//phpCAS::forceAuthentication();
}
//if ($action=='login')
if (isset($_REQUEST['action']) && $_REQUEST['action']=='login')
{
phpCAS::forceAuthentication();
}
// check CAS authentication
$auth = phpCAS::checkAuthentication();
$_SESSION['CASauthenticated'] = $auth;
if($auth)
{
/**
* User is authenticated from CAS, with this, he gets full Superadmin rights, when successful authenticates with CAS.
* This is very basic though, you should try to use what your CAS server provides you with (ROLES, rights, extra attibutes, etc.)
*
*/
$_SESSION['user'] = phpCAS::getUser();
$_SESSION['loginID'] = 1;
/**
* @var unknown_type
*/
$_SESSION['USER_RIGHT_CREATE_SURVEY'] = 1;
$_SESSION['USER_RIGHT_CONFIGURATOR'] = 1;
$_SESSION['USER_RIGHT_CREATE_USER'] = 1;
$_SESSION['USER_RIGHT_DELETE_USER'] = 1;
$_SESSION['USER_RIGHT_SUPERADMIN'] = 1;
$_SESSION['USER_RIGHT_MANAGE_TEMPLATE'] = 1;
$_SESSION['USER_RIGHT_MANAGE_LABEL'] = 1;
// Passwort notify for not changed Passwort have to be false when authing over CAS (or Warnings appear, because it is not set)
$_SESSION['pw_notify'] = false;
}
else
{
phpCAS::forceAuthentication();
}
// echo $auth;
// echo phpCAS::getUser();
// echo phpCAS::getVersion();
}
?>

View File

@@ -1,66 +1,91 @@
<?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: preview.php 4907 2008-05-24 10:21:08Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
require_once(dirname(__FILE__).'/sessioncontrol.php');
require_once(dirname(__FILE__).'/../qanda.php');
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($qid)) {$qid=returnglobal('qid');}
if (empty($surveyid)) {die("No SID provided.");}
if (empty($qid)) {die("No QID provided.");}
if (!isset($_GET['lang']) || $_GET['lang'] == "")
{
$language = GetBaseLanguageFromSurveyID($surveyid);
} else {
$language = $_GET['lang'];
}
$_SESSION['s_lang'] = $language;
$clang = new limesurvey_lang($language);
$qquery = 'SELECT * FROM '.db_table_name('questions')." WHERE sid='$surveyid' AND qid='$qid' AND language='{$language}'";
$qresult = db_execute_assoc($qquery);
$qrows = $qresult->FetchRow();
$ia = array(0 => $qid, 1 => "FIELDNAME", 2 => $qrows['title'], 3 => $qrows['question'], 4 => $qrows['type'], 5 => $qrows['gid'],
6 => $qrows['mandatory'], 7 => $qrows['other']);
$answers = retrieveAnswers($ia);
$thistpl="$publicdir/templates";
doHeader();
//echo "\t\t\t\t<div id='question'";
echo "<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->
<script type='text/javascript'>
<!--
function checkconditions(value, name, type)
{
}
//-->
</script>";
echo "<form method='post' action='index.php' id='limesurvey' name='limesurvey'>\n";
$question="<label for='$answers[0][7]'>" . $answers[0][0] . "</label>";
$answer=$answers[0][1];
$help=$answers[0][2];
$questioncode=$answers[0][5];
echo templatereplace(file_get_contents("$thistpl/preview.pstpl"));
echo "</form>\n";
echo "</html>\n";
exit;
?>
<?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: preview.php 7389 2009-08-02 20:22:15Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");
require_once(dirname(__FILE__).'/sessioncontrol.php');
require_once(dirname(__FILE__).'/../qanda.php');
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($qid)) {$qid=returnglobal('qid');}
if (empty($surveyid)) {die("No SID provided.");}
if (empty($qid)) {die("No QID provided.");}
if (!isset($_GET['lang']) || $_GET['lang'] == "")
{
$language = GetBaseLanguageFromSurveyID($surveyid);
} else {
$language = $_GET['lang'];
}
$_SESSION['s_lang'] = $language;
$clang = new limesurvey_lang($language);
$thissurvey=getSurveyInfo($surveyid);
$qquery = 'SELECT * FROM '.db_table_name('questions')." WHERE sid='$surveyid' AND qid='$qid' AND language='{$language}'";
$qresult = db_execute_assoc($qquery);
$qrows = $qresult->FetchRow();
$ia = array(0 => $qid,
1 => "FIELDNAME",
2 => $qrows['title'],
3 => $qrows['question'],
4 => $qrows['type'],
5 => $qrows['gid'],
6 => $qrows['mandatory'],
7 => $qrows['other']);
$answers = retrieveAnswers($ia);
$thistpl="$templaterootdir/".$thissurvey['template'];
doHeader();
$dummy_js = '
<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->
<script type="text/javascript">
<!--
function checkconditions(value, name, type)
{
}
//-->
</script>
<form method="post" action="index.php" id="limesurvey" name="limesurvey">
';
$question="<label for='$answers[0][7]'>" . $answers[0][0] . "</label>";
$answer=$answers[0][1];
$help=$answers[0][2];
$questioncode=$answers[0][5];
$content = templatereplace(file_get_contents("$thistpl/startpage.pstpl"));
$content .= templatereplace(file_get_contents("$thistpl/startgroup.pstpl"));
$content .= templatereplace(file_get_contents("$thistpl/question.pstpl"));
$content .= templatereplace(file_get_contents("$thistpl/endgroup.pstpl")).$dummy_js;
$content .= templatereplace(file_get_contents("$thistpl/endpage.pstpl"));
if($qrows['mandatory'] == 'Y')
{
$mandatory = ' mandatory';
}
else
{
$mandatory = '';
}
$content = str_replace('{QUESTION_CLASS}' , question_class($qrows['type']) . $mandatory , $content);
echo $content;
echo "</html>\n";
exit;
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: questionquota.php 3571 2007-12-19 10:32:25Z machaven $
* $Id: quota.php 7132 2009-06-17 14:18:05Z c_schmitz $
*/
include_once("login_check.php"); //Login Check dies also if the script is started directly
@@ -68,6 +68,34 @@ function getQuotaAnswers($qid,$surveyid,$quota_id)
}
}
if ($qtype['type'] == 'L' || $qtype['type'] == 'O' || $qtype['type'] == '!')
{
$query = "SELECT * FROM ".db_table_name('quota_members')." WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$query = "SELECT code,answer FROM ".db_table_name('answers')." WHERE qid='{$qid}'";
$ansresult = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$answerlist = array();
while ($dbanslist = $ansresult->FetchRow())
{
$answerlist[$dbanslist['code']] = array('Title'=>$qtype['title'],
'Display'=>substr($dbanslist['answer'],0,40),
'code'=>$dbanslist['code']);
}
if ($result->RecordCount() > 0)
{
while ($quotalist = $result->FetchRow())
{
$answerlist[$quotalist['code']]['rowexists'] = '1';
}
}
}
if ($qtype['type'] == 'A')
{
$query = "SELECT * FROM ".db_table_name('quota_members')." WHERE sid='{$surveyid}' and qid='{$qid}' and quota_id='{$quota_id}'";
@@ -188,20 +216,119 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
if (!isset($quotasoutput)) $quotasoutput = "";
if($subaction == "insertquota")
{
if(!isset($_POST['quota_limit']) || $_POST['quota_limit'] < 1)
{
$_POST['quota_limit'] = 1;
}
$_POST = array_map('db_quote', $_POST);
$query = "INSERT INTO ".db_table_name('quota')." (sid,name,qlimit,action) VALUES ('$surveyid','{$_POST['quota_name']}','{$_POST['quota_limit']}','{$_POST['quota_action']}')";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
$query = "INSERT INTO ".db_table_name('quota')." (sid,name,qlimit,action,autoload_url)
VALUES ('$surveyid','{$_POST['quota_name']}','{$_POST['quota_limit']}','1', '1')";
$connect->Execute($query) or safe_die("Error inserting limit".$connect->ErrorMsg());
$quotaid=$connect->Insert_Id(db_table_name_nq('quota'),"id");
//Get the languages used in this survey
$langs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$langs[] = $baselang;
//Iterate through each language, and make sure there is a quota message for it
$errorstring = '';
foreach ($langs as $lang)
{
if (!$_POST['quotals_message_'.$lang]) { $errorstring.= GetLanguageNameFromCode($lang,false)."\\n";}
}
if ($errorstring!='')
{
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Quota could not be added.\\n\\nIt is missing a quota message for the following languages","js").":\\n".$errorstring."\")\n //-->\n</script>\n";
}
else
//All the required quota messages exist, now we can insert this info into the database
{
require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
foreach ($langs as $lang) //Iterate through each language
{
//Clean XSS
if ($filterxsshtml)
{
$_POST['quotals_message_'.$lang]=$myFilter->process($_POST['quotals_message_'.$lang]);
}
else
{
$_POST['quotals_message_'.$lang] = html_entity_decode($_POST['quotals_message_'.$lang], ENT_QUOTES, "UTF-8");
}
// Fix bug with FCKEditor saving strange BR types
$_POST['quotals_message_'.$lang]=fix_FCKeditor_text($_POST['quotals_message_'.$lang]);
include_once(dirname(__FILE__) . '/../quexs.php');
//Now save the language to the database:
$query = "INSERT INTO ".db_table_name('quota_languagesettings')." (quotals_quota_id, quotals_language, quotals_name, quotals_message, quotals_url, quotals_urldescrip)
VALUES ('$quotaid', '$lang', '".db_quote($_POST['quota_name'])."', '".db_quote($_POST['quotals_message_'.$lang])."', '".QUEXS_URL."rs_quota_end.php', '".QUEXS_URL."rs_quota_end.php')";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
}
} //End insert language based components
$viewquota = "1";
}
} //End foreach $lang
if($subaction == "modifyquota")
{
$_POST = array_map('db_quote', $_POST);
$query = "UPDATE ".db_table_name('quota')." SET name='{$_POST['quota_name']}', qlimit='{$_POST['quota_limit']}', action='{$_POST['quota_action']}' where id='{$_POST['quota_id']}' ";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
$viewquota = "1";
$query = "UPDATE ".db_table_name('quota')."
SET name='{$_POST['quota_name']}',
qlimit='{$_POST['quota_limit']}'
WHERE id='{$_POST['quota_id']}' ";
$connect->Execute($query) or safe_die("Error modifying quota".$connect->ErrorMsg());
//Get the languages used in this survey
$langs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$langs[] = $baselang;
//Iterate through each language, and make sure there is a quota message for it
$errorstring = '';
foreach ($langs as $lang)
{
if (!$_POST['quotals_message_'.$lang]) { $errorstring.= GetLanguageNameFromCode($lang,false)."\\n";}
}
if ($errorstring!='')
{
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Quota could not be added.\\n\\nIt is missing a quota message for the following languages","js").":\\n".$errorstring."\")\n //-->\n</script>\n";
}
else
//All the required quota messages exist, now we can insert this info into the database
{
require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
foreach ($langs as $lang) //Iterate through each language
{
//Clean XSS
if ($filterxsshtml)
{
$_POST['quotals_message_'.$lang]=$myFilter->process($_POST['quotals_message_'.$lang]);
}
else
{
$_POST['quotals_message_'.$lang] = html_entity_decode($_POST['quotals_message_'.$lang], ENT_QUOTES, "UTF-8");
}
// Fix bug with FCKEditor saving strange BR types
$_POST['quotals_message_'.$lang]=fix_FCKeditor_text($_POST['quotals_message_'.$lang]);
//Now save the language to the database:
$query = "UPDATE ".db_table_name('quota_languagesettings')."
SET quotals_name='".db_quote($_POST['quota_name'])."',
quotals_message='".db_quote($_POST['quotals_message_'.$lang])."'
WHERE quotals_quota_id = '{$_POST['quota_id']}'
AND quotals_language = '$lang'";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
}
} //End insert language based components
$viewquota = "1";
}
if($subaction == "insertquotaanswer")
@@ -216,29 +343,35 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
if($subaction == "quota_delans")
{
$_POST = array_map('db_quote', $_POST);
$query = "DELETE FROM ".db_table_name('quota_members')." WHERE qid='{$_POST['quota_qid']}' and code='{$_POST['quota_anscode']}'";
$query = "DELETE FROM ".db_table_name('quota_members')."
WHERE id = '{$_POST['quota_member_id']}'
AND qid='{$_POST['quota_qid']}' and code='{$_POST['quota_anscode']}'";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
$viewquota = "1";
}
if($subaction == "quota_delquota")
{
$_POST = array_map('db_quote', $_POST);
$query = "DELETE FROM ".db_table_name('quota')." WHERE id='{$_POST['quota_id']}'";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
$query = "DELETE FROM ".db_table_name('quota_languagesettings')." WHERE quotals_quota_id='{$_POST['quota_id']}'";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
$query = "DELETE FROM ".db_table_name('quota_members')." WHERE quota_id='{$_POST['quota_id']}'";
$connect->Execute($query) or safe_die($connect->ErrorMsg());
$viewquota = "1";
}
if ($subaction == "quota_editquota")
{
if (isset($_GET['quota_id'])) $_POST['quota_id'] = $_GET['quota_id'];
$_POST = array_map('db_quote', $_POST);
$query = "SELECT * FROM ".db_table_name('quota')." where id='{$_POST['quota_id']}'";
$query = "SELECT * FROM ".db_table_name('quota')."
WHERE id='{$_POST['quota_id']}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$quotainfo = $result->FetchRow();
@@ -263,19 +396,57 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
</blockquote></td>
<td align="left"><input name="quota_limit" type="text" size="12" maxlength="8" value="'.$quotainfo['qlimit'].'"></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong>'.$clang->gT("Quota Action").':</strong></p>
</blockquote></td>
<td align="left"> <select name="quota_action">
<option value ="1" ';
if($quotainfo['action'] == 1) $quotasoutput .= "selected";
$quotasoutput .='>'.$clang->gT("Terminate Survey") .'</option>
<option value ="2" ';
if($quotainfo['action'] == 2) $quotasoutput .= "selected";
$quotasoutput .= '>'.$clang->gT("Terminate Survey With Warning") .'</option>
</select></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>';
$langs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_push($langs,$baselang);
require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
$quotasoutput .= '
<div class="tab-pane" id="tab-pane-quota-'.$surveyid.'">'."\n\n";
foreach ($langs as $lang)
{
//Get this one
$langquery = "SELECT * FROM ".db_table_name('quota_languagesettings')." WHERE quotals_quota_id='{$_POST['quota_id']}' AND quotals_language = '$lang'";
$langresult = db_execute_assoc($langquery) or safe_die($connect->ErrorMsg());
$langquotainfo = $langresult->FetchRow();
$quotasoutput .= '
<div class="tab-page">
<h2 class="tab">'.GetLanguageNameFromCode($lang,false);
if ($lang==$baselang) {$quotasoutput .= '('.$clang->gT("Base Language").')';}
$quotasoutput .= "</h2>";
$quotasoutput.='
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tr>
<td valign="top">
<table width="100%" border="0">
<tbody>
<tr class="evenrow">
<td align="right" valign="top"><blockquote>
<p><strong>'.$clang->gT("Quota message").':</strong></p>
</blockquote></td>
<td align="left"> <textarea name="quotals_message_'.$lang.'" cols="60" rows="6">'.$langquotainfo['quotals_message'].'</textarea></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</div>';
};
$quotasoutput .= '
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tr>
<td valign="top">
<table width="100%" border="0">
<tbody>
<tr align="left" class="evenrow">
<td>&nbsp;</td>
<td><table width="30%"><tr><td align="left"><input name="submit" type="submit" value="'.$clang->gT("Update Quota").'" />
@@ -297,10 +468,16 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
</table>';
}
$totalquotas=0;
$totalcompleted=0;
$csvoutput=array();
if (($action == "quotas" && !isset($subaction)) || isset($viewquota))
{
$query = "SELECT * FROM ".db_table_name('quota')." where sid='".$surveyid."'";
$query = "SELECT * FROM ".db_table_name('quota')." , ".db_table_name('quota_languagesettings')."
WHERE ".db_table_name('quota').".id = ".db_table_name('quota_languagesettings').".quotals_quota_id
AND sid='".$surveyid."'
AND quotals_language = '".$baselang."'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
$quotasoutput .='<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
@@ -326,7 +503,7 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
while ($quotalisting = $result->FetchRow())
{
$quotasoutput .='<tr>
<td align="center">'.$quotalisting['name'].'</td>
<td align="center"><a name="quota_'.$quotalisting['id'].'">'.$quotalisting['name'].'</a></td>
<td align="center">';
if ($quotalisting['active'] == 1)
{
@@ -342,9 +519,15 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
} elseif ($quotalisting['action'] == 2) {
$quotasoutput .= $clang->gT("Terminate Survey With Warning");
}
$totalquotas+=$quotalisting['qlimit'];
$completed=get_quotaCompletedCount($surveyid, $quotalisting['id']);
$highlight=($completed >= $quotalisting['qlimit']) ? "" : "style='color: red'"; //Incomplete quotas displayed in red
$totalcompleted=$totalcompleted+$completed;
$csvoutput[]=$quotalisting['name'].",".$quotalisting['qlimit'].",".$completed.",".($quotalisting['qlimit']-$completed)."\r\n";
$quotasoutput .='</td>
<td align="center">'.$quotalisting['qlimit'].'</td>
<td align="center">N/A</td>
<td align="center" '.$highlight.'>'.$completed.'</td>
<td align="center" style="padding: 3px;">
<table width="100%"><tr><td align="center">
<form action="'.$scriptname.'" method="post">
@@ -396,6 +579,7 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
<input name="submit" type="submit" id="submit" value="'.$clang->gT("Remove").'">
<input type="hidden" name="sid" value="'.$surveyid.'" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="quota_member_id" value="'.$quota_questions['id'].'" />
<input type="hidden" name="quota_qid" value="'.$quota_questions['qid'].'" />
<input type="hidden" name="quota_anscode" value="'.$quota_questions['code'].'" />
<input type="hidden" name="subaction" value="quota_delans" />
@@ -418,16 +602,24 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
}
$quotasoutput .='<tr>
<td align="center"><form action="'.$scriptname.'" method="post">
<td align="center">&nbsp;</td>
<td align="center"><a name="quota_end">&nbsp;</a></td>
<td align="center">&nbsp;</td>
<td align="center">'.$totalquotas.'</td>
<td align="center">&nbsp;</td>
<td align="center" style="padding: 3px;"><form action="'.$scriptname.'" method="post">
<input name="submit" type="submit" id="quota_new" value="'.$clang->gT("Add New Quota").'">
<input type="hidden" name="sid" value="'.$surveyid.'" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="subaction" value="new_quota" /></form></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center"><a name="quota_end">&nbsp;</a></td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center" style="padding: 3px;">&nbsp;</td>
<td align="center">'.$totalquotas.'</td>
<td align="center">'.$totalcompleted.'</td>
<td align="center" style="padding: 3px;"<input type="button" value="'.$clang->gT("Quick CSV Report").'" onClick="window.open(\'admin.php?action=quotas&amp;sid='.$surveyid.'&amp;quickreport=y\', \'_top\')"></td>
</tr>
</tbody>
</table>
@@ -436,12 +628,22 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
</table>';
}
if(isset($_GET['quickreport']) && $_GET['quickreport'])
{
header("Content-Disposition: attachment; filename=results-survey".$surveyid.".csv");
header("Content-type: text/comma-separated-values; charset=UTF-8");
echo $clang->gT("Quota Name").",".$clang->gT("Limit").",".$clang->gT("Completed").",".$clang->gT("Remaining")."\r\n";
foreach($csvoutput as $line)
{
echo $line;
}
die;
}
if($subaction == "new_answer" || ($subaction == "new_answer_two" && !isset($_POST['quota_qid'])))
{
if ($subaction == "new_answer_two") $_POST['quota_id'] = $_POST['quota_id'];
$allowed_types = "(type ='G' or type ='M' or type ='Y' or type ='A' or type ='B' or type ='I')";
$allowed_types = "(type ='G' or type ='M' or type ='Y' or type ='A' or type ='B' or type ='I' or type = 'L' or type='O' or type='!')";
$query = "SELECT qid, title, question FROM ".db_table_name('questions')." WHERE $allowed_types AND sid='$surveyid' AND language='{$baselang}'";
$result = db_execute_assoc($query) or safe_die($connect->ErrorMsg());
if ($result->RecordCount() == 0)
@@ -534,7 +736,7 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
</table>';
} else
{
$quotasoutput .='<form action="'.$scriptname.'" method="post">
$quotasoutput .='<form action="'.$scriptname.'#quota_'.$_POST['quota_id'].'" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tr>
<td valign="top">
@@ -585,8 +787,8 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
if ($subaction == "new_quota")
{
$quotasoutput .='<form action="'.$scriptname.'" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
$quotasoutput .='<form action="'.$scriptname.'" method="post" name="addnewquotaform">';
$quotasoutput.=' <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tr>
<td valign="top">
<table width="100%" border="0">
@@ -598,38 +800,66 @@ if($sumrows5['edit_survey_property'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1)
<td align="right"><blockquote>
<p><strong>'.$clang->gT("Quota Name").':</strong></p>
</blockquote></td>
<td align="left"> <input name="quota_name" type="text" size="30" maxlength="255"></td>
<td align="left"> <input name="quota_name" type="text" size="30" maxlength="255" /></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong>'.$clang->gT("Quota Limit").':</strong></p>
</blockquote></td>
<td align="left"><input name="quota_limit" type="text" size="12" maxlength="8"></td>
<td align="left"><input name="quota_limit" type="text" size="12" maxlength="8" /></td>
</tr>
<tr class="evenrow">
<td align="right"><blockquote>
<p><strong>'.$clang->gT("Quota Action").':</strong></p>
</blockquote></td>
<td align="left"> <select name="quota_action">
<option value ="1">'.$clang->gT("Terminate Survey") .'</option>
<option value ="2">'.$clang->gT("Terminate Survey With Warning") .'</option>
</select></td>
</tr>
<tr align="left" class="evenrow">
<td>&nbsp;</td>
<td><input name="submit" type="submit" value="'.$clang->gT("Add New Quota").'" />
<input type="hidden" name="sid" value="'.$surveyid.'" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="subaction" value="insertquota" />
</tbody>
</table>
</td>
</tr>
</table>
';
</form>
$langs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_push($langs,$baselang);
require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
$thissurvey=getSurveyInfo($surveyid);
$quotasoutput .= '
<div class="tab-pane" id="tab-pane-quota-'.$surveyid.'">'."\n\n";
foreach ($langs as $lang)
{
$quotasoutput .= '
<div class="tab-page">
<h2 class="tab">'.GetLanguageNameFromCode($lang,false);
if ($lang==$baselang) {$quotasoutput .= '('.$clang->gT("Base Language").')';}
$quotasoutput .= "</h2>";
$quotasoutput.='
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F8F8FF">
<tr>
<td valign="top">
<table width="100%" border="0">
<tbody>
<tr class="evenrow">
<td align="right" valign="top"><blockquote>
<p><strong>'.$clang->gT("Quota message").':</strong></p>
</blockquote></td>
<td align="left"> <textarea name="quotals_message_'.$lang.'" cols="60" rows="6">'.$clang->gT("Sorry your responses have exceeded a quota on this survey.").'</textarea></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>';
</table>
</div>';
};
$quotasoutput .= '
<input type="hidden" name="sid" value="'.$surveyid.'" />
<input type="hidden" name="action" value="quotas" />
<input type="hidden" name="subaction" value="insertquota" />
</div>
<input name="submit" type="submit" value="'.$clang->gT("Add New Quota").'" />
</form>';
}
}

View File

@@ -0,0 +1,41 @@
# LimeSurvey Group Dump
# DBVersion 130
# This is a dumped group from the LimeSurvey Script
# http://www.limesurvey.org/
# Do not change this header!
#
# GROUPS TABLE
#
"gid","sid","group_name","group_order","description","language"
"43","10","Student BIO","6","Fragebogen für Biologistudenten<br />","de"
#
# QUESTIONS TABLE
#
"qid","sid","gid","type","title","question","preg","help","other","mandatory","lid","lid1","question_order","language"
"211","10","43","L","1","Tragen Sie Biolatschen?<br />","","","N","N","0","0","1","de"
#
# ANSWERS TABLE
#
"qid","code","answer","default_value","sortorder","language"
"211","1","ja","N","1","de"
"211","2","nein","N","2","de"
"211","3","geht dich nix an!","Y","3","de"
#
# CONDITIONS TABLE
#
#
# LABELSETS TABLE
#
#
# LABELS TABLE
#
#
# QUESTION_ATTRIBUTES TABLE
#
1 # LimeSurvey Group Dump
2 # DBVersion 130
3 # This is a dumped group from the LimeSurvey Script
4 # http://www.limesurvey.org/
5 # Do not change this header!
6 #
7 # GROUPS TABLE
8 #
9 gid sid group_name group_order description language
10 43 10 Student BIO 6 Fragebogen für Biologistudenten<br /> de
11 #
12 # QUESTIONS TABLE
13 #
14 qid sid gid type title question preg help other mandatory lid lid1 question_order language
15 211 10 43 L 1 Tragen Sie Biolatschen?<br /> N N 0 0 1 de
16 #
17 # ANSWERS TABLE
18 #
19 qid code answer default_value sortorder language
20 211 1 ja N 1 de
21 211 2 nein N 2 de
22 211 3 geht dich nix an! Y 3 de
23 #
24 # CONDITIONS TABLE
25 #
26 #
27 # LABELSETS TABLE
28 #
29 #
30 # LABELS TABLE
31 #
32 #
33 # QUESTION_ATTRIBUTES TABLE
34 #

View File

@@ -0,0 +1,43 @@
# LimeSurvey Group Dump
# DBVersion 130
# This is a dumped group from the LimeSurvey Script
# http://www.limesurvey.org/
# Do not change this header!
#
# GROUPS TABLE
#
"gid","sid","group_name","group_order","description","language"
"41","10","Student BWL","4","Fragemodul für BWL Studenten<br />","de"
#
# QUESTIONS TABLE
#
"qid","sid","gid","type","title","question","preg","help","other","mandatory","lid","lid1","question_order","language"
"213","10","41","L","1","Wieviel ist Ihr Auto noch wert?<br />","","","N","N","0","0","1","de"
#
# ANSWERS TABLE
#
"qid","code","answer","default_value","sortorder","language"
"213","1","nicht mehr als 1000€","N","1","de"
"213","2","nicht mehr als 10.000€","N","2","de"
"213","3","nicht mehr als 30.000€","N","3","de"
"213","4","keine Ahnung, hab ich von Papa","N","4","de"
"213","5","das Auto gehört zum Chauffeuerdienst","N","5","de"
#
# CONDITIONS TABLE
#
#
# LABELSETS TABLE
#
#
# LABELS TABLE
#
#
# QUESTION_ATTRIBUTES TABLE
#
1 # LimeSurvey Group Dump
2 # DBVersion 130
3 # This is a dumped group from the LimeSurvey Script
4 # http://www.limesurvey.org/
5 # Do not change this header!
6 #
7 # GROUPS TABLE
8 #
9 gid sid group_name group_order description language
10 41 10 Student BWL 4 Fragemodul für BWL Studenten<br /> de
11 #
12 # QUESTIONS TABLE
13 #
14 qid sid gid type title question preg help other mandatory lid lid1 question_order language
15 213 10 41 L 1 Wieviel ist Ihr Auto noch wert?<br /> N N 0 0 1 de
16 #
17 # ANSWERS TABLE
18 #
19 qid code answer default_value sortorder language
20 213 1 nicht mehr als 1000€ N 1 de
21 213 2 nicht mehr als 10.000€ N 2 de
22 213 3 nicht mehr als 30.000€ N 3 de
23 213 4 keine Ahnung, hab ich von Papa N 4 de
24 213 5 das Auto gehört zum Chauffeuerdienst N 5 de
25 #
26 # CONDITIONS TABLE
27 #
28 #
29 # LABELSETS TABLE
30 #
31 #
32 # LABELS TABLE
33 #
34 #
35 # QUESTION_ATTRIBUTES TABLE
36 #

View File

@@ -0,0 +1,35 @@
# LimeSurvey Group Dump
# DBVersion 133
# This is a dumped group from the LimeSurvey Script
# http://www.limesurvey.org/
# Do not change this header!
#
# GROUPS TABLE
#
"gid","sid","group_name","group_order","description","language"
"562","666","Zusätzliche Fragen","1","","de"
#
# QUESTIONS TABLE
#
#
# ANSWERS TABLE
#
#
# CONDITIONS TABLE
#
#
# LABELSETS TABLE
#
#
# LABELS TABLE
#
#
# QUESTION_ATTRIBUTES TABLE
#
1 # LimeSurvey Group Dump
2 # DBVersion 133
3 # This is a dumped group from the LimeSurvey Script
4 # http://www.limesurvey.org/
5 # Do not change this header!
6 #
7 # GROUPS TABLE
8 #
9 gid sid group_name group_order description language
10 562 666 Zusätzliche Fragen 1 de
11 #
12 # QUESTIONS TABLE
13 #
14 #
15 # ANSWERS TABLE
16 #
17 #
18 # CONDITIONS TABLE
19 #
20 #
21 # LABELSETS TABLE
22 #
23 #
24 # LABELS TABLE
25 #
26 #
27 # QUESTION_ATTRIBUTES TABLE
28 #

View File

@@ -0,0 +1,43 @@
# LimeSurvey Group Dump
# DBVersion 130
# This is a dumped group from the LimeSurvey Script
# http://www.limesurvey.org/
# Do not change this header!
#
# GROUPS TABLE
#
"gid","sid","group_name","group_order","description","language"
"42","10","Student INF","5","Fragebogen für Informatik Studenten<br />","de"
#
# QUESTIONS TABLE
#
"qid","sid","gid","type","title","question","preg","help","other","mandatory","lid","lid1","question_order","language"
"212","10","42","L","1","Vieviele Computer haben Sie zu Hause?<br />","","Taschenrechner und Smartphones zählen nicht mit<br />","N","N","0","0","1","de"
#
# ANSWERS TABLE
#
"qid","code","answer","default_value","sortorder","language"
"212","1","keinen","N","1","de"
"212","2","einen","N","2","de"
"212","3","mehr als einen","N","3","de"
"212","4","mehr als 5","N","4","de"
"212","5","da muß ich erstmal zählen gehen","N","5","de"
#
# CONDITIONS TABLE
#
#
# LABELSETS TABLE
#
#
# LABELS TABLE
#
#
# QUESTION_ATTRIBUTES TABLE
#
1 # LimeSurvey Group Dump
2 # DBVersion 130
3 # This is a dumped group from the LimeSurvey Script
4 # http://www.limesurvey.org/
5 # Do not change this header!
6 #
7 # GROUPS TABLE
8 #
9 gid sid group_name group_order description language
10 42 10 Student INF 5 Fragebogen für Informatik Studenten<br /> de
11 #
12 # QUESTIONS TABLE
13 #
14 qid sid gid type title question preg help other mandatory lid lid1 question_order language
15 212 10 42 L 1 Vieviele Computer haben Sie zu Hause?<br /> Taschenrechner und Smartphones zählen nicht mit<br /> N N 0 0 1 de
16 #
17 # ANSWERS TABLE
18 #
19 qid code answer default_value sortorder language
20 212 1 keinen N 1 de
21 212 2 einen N 2 de
22 212 3 mehr als einen N 3 de
23 212 4 mehr als 5 N 4 de
24 212 5 da muß ich erstmal zählen gehen N 5 de
25 #
26 # CONDITIONS TABLE
27 #
28 #
29 # LABELSETS TABLE
30 #
31 #
32 # LABELS TABLE
33 #
34 #
35 # QUESTION_ATTRIBUTES TABLE
36 #

View File

@@ -0,0 +1,79 @@
<?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: lsrc.config.php 6937 2009-05-26 12:28:29Z wahrendorff $
*
*/
### Including
// including LimeSurvey configs, for database variables and more...
// only include if this config is not used to save a survey.csv for the lsrc
if(!isset($export4lsrc))
{
include("../../config-defaults.php");
include("../../config.php");
require_once(dirname(__FILE__).'/../../common.php');
}
### Error Handling
// simple debug Option
ini_set("error_reporting","E_ALL");
//specialized debug option, true for own debuglog
$lsrcDebug = true;
$lsrcDebugLog = "lsrc.log";
// error log enabled, hint(.../apache/logs/error.log) this is very handy while developing, since SOAP does not echo php error messages to the client
// it's also recommended to set this in productive environment
ini_set("log_errors", "1");
### Caching
//we don't like caching while testing, so we disable it...
//for productiv use it's recommended to set this to 1 or comment it out for webserver default
ini_set("soap.wsdl_cache_enabled", "0");
### Security
// enable for ssl connections
// this is for wsdl generation, on true the url to the server in the wsdl beginns with https instead of http
$lsrcOverSSL=true; //default: false
// enable if you use a certificate for the Connections
// IMPORTANT NOTE: your Client need the same certificate to connect with.
$useCert=false; //default: false
// path to your local certificate
$sslCert='D:\\xampp\apache\privkey.pem';
//C:\\path\myCert.pem
### Variables
// path to the wsdl definition for this server... normally it is in the same directory, so you don't need to change it.
$wsdl= $homedir."/remotecontrol/lsrc.wsdl"; //default: $homedir."/remotecontrol/lsrc.wsdl";
/**
* These are the Dirs where the prepared survey csv's are or have to be.
* one for the core surveys,
* one for addable groups,
* one for addable questions
*/
$coreDir = "./surveys/";
$modDir = "./groups/";
$queDir = "./questions/";
//seperator for Tokens in sInsertToken function
$sLsrcSeparator = ","; //default: ","
//set the Seperators for Participant Datasets in sInsertParticipants
$sDatasetSeperator = "::"; //default: "::"
$sDatafieldSeperator = ";"; //default: ";"
?>

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,728 @@
<?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: lsrc.testclient.php 7056 2009-06-10 12:11:14Z wahrendorff $
*
*/
$wsdl = isset($_REQUEST['wsdl'])?$_REQUEST['wsdl']:'';
#####################################################################
## Configuration Parameters
//set this to your limesurvey installation path for the "test survey" link to work
$limeUrl='https://localhost/limesource/limesurvey';
//We need authentication for every function, so just write the logindata once for all (this is the default)
$user ="admin";
$pass ="password";
//we don't like caching while testing, so we disable it
ini_set("soap.wsdl_cache_enabled", 0);
// errors are ok, but warnings just destroy our layout while they have nothing to say (in this case, sometimes warnings are useful!)
ini_set("error_reporting", "E_ALL & ~E_WARNING");
if($wsdl=='')
{
// give full uri of the wsdl from the webservice you want to connect to...
// THIS NEEDS TO BE CHANGED to the webservice you want to connect, localhost is just for testing on one machine...
// change http to https if you want to use ssl connection to the wsdl...
$wsdl=$limeUrl.'/admin/remotecontrol/lsrc.server.php?wsdl';
}
// fixed certificate, if U use some... you need this if you have an own trusted certificate.
// If you dont know what I am taking about, just leave this option untouched.
//$cert='allinone.pem';
##
#####################################################################
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>LimeSurvey RC Testclient</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type='text/css'>
<!--
body {
background-color: black;
color: white;
}
div {
background-color: white;
color: black;
padding: 0.2em;
}
a:link{
color:darkgreen;
fontweight:bold;
}
a:visited{
color:darkgreen;
fontweight:bold;
}
a:hover{
color:green;
fontweight:bold;
}
p{
border-top:solid 1px white;
margin-bottom:0.5em;
margin-top:0.2em;
}
-->
</style>
<?php
// Checkfunction für die soap Klasse und die benötigte libxml version...
function soapCheck ($path2wsdl)
{
$soapCheck ='<div style="color:white;background-color:black;border: 1px solid green;">';
if(class_exists(SoapClient))
{
$soapCheck .= "<div style='float:left;background:green;color:white;padding:5px;margin-right:5px;'>
SOAP Erweiterung existiert</div> ";
}
else
{
$soapCheck .= "<div style='float:left;background:red;color:white;padding:5px;margin-right:5px;'>
SOAP Erweiterung fehlt!</div> ";
}
if(LIBXML_VERSION>=20540)
{
$soapCheck .= " <div style='float:left;background:green;color:white;padding:5px;margin-right:5px;'>
libXML version '".LIBXML_DOTTED_VERSION."' OK</div>";
}
else
{
$soapCheck .= " <div style='float:left;background:red;color:white;padding:5px;margin-right:5px;'>
libXML version '".(LIBXML_DOTTED_VERSION )."' nicht OK</div>";
}
// Check ob eine wsdl Datei gefunden werden kann
//$wsdlfile = ;
ini_set("allow_url_fopen", 1);
if (!fopen($path2wsdl,"r"))
{
$soapCheck .= "<div style='float:left;background:red;color:white;padding:5px;'>
Der Pfad zur WSDL Datei ist nicht korrekt oder die WSDL Datei fehlt!</div>";
}
else
{
$soapCheck .= "<div style='float:left;background:green;color:white;padding:5px;'>
WSDL Datei konnte gefunden werden</div>";
}
$soapCheck .= "<div style='clear:both;background-color:black;'>
<form action='".$_SERVER['PHP_SELF']."' method='post'>
<input type='text' name='wsdl' size='97' value='".$path2wsdl."' />
<input type='submit' name='validate' value='neu checken!' />
</form>
</div></div>";
return $soapCheck;
}
//// We initiate a SOAPclient Object and give the ssl-certificate, if wished:
//$cert = 'D:\\xampp\apache\privkey.pem';
if(isset($cert) && $cert!="")
{
ini_set("allow_url_fopen", 1);
$file = fopen($wsdl,"r");
if(class_exists(SoapClient) && $file!=FALSE)
{
/**
* TODO: no documentation in PHP manual... no doc here... Can't tell you what to do in order to get Communication working with fixed Certificates
* Can't even say, which certificates, how they have to be (.pem, .crt, .key etc.?)
* Own Microkosmos for Geeks only... Sad truth...
*/
$context = array(
'ssl'=> array(
'verify_peer' => false,
'allow_self_signed' => true,
'local_cert' => $cert
)
);
$stream_context = stream_context_create($context);
$client = new SoapClient($wsdl, array('soap_version' => SOAP_1_1,
'trace' => 1,
'stream_context' => $stream_context
));
}
}
else
{
ini_set("allow_url_fopen", 1);
$file = fopen($wsdl,"r");
if(class_exists(SoapClient) && $file!=FALSE)
{
$client = new SoapClient($wsdl, array('soap_version' => SOAP_1_1,
'trace' => 1));
}
}
if($file!=FALSE)
{
try
{ $mods = $client->sAvailableModules($user, "password", "mod");}
catch (SoapFault $fault)
{ $mods .= "<br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";}
}
if($file!=FALSE)
{
try
{ $cores = $client->sAvailableModules($user, "password", "core");}
catch (SoapFault $fault)
{ $cores .= "<br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";}
}
$iVid = $_REQUEST['sid'];
//$sVbes = utf8_encode($sVbes);
//$user = $_REQUEST['user'];
//$pass = $_REQUEST['password'];
// Calling the desired function //XXX
reset($_REQUEST);
while(list($key, $value) = each($_REQUEST))
{
if(substr($key,0,8)=="sendMail")
{
$iVid = $_REQUEST['sid'];
$sType = $_REQUEST['type'];
$maxemails = $_REQUEST['maxemails'];
$subject = $_REQUEST['subject'];
$mailText = $_REQUEST['mailText'];
try
{
$sReturn = $client->sSendEmail($user, $pass, $iVid, $sType, $maxemails, $subject, $mailText);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,8)=="getField")
{
$iVid = $_REQUEST['sid'];
try
{
$sReturn = $client->sGetFieldmap($user, $pass, $iVid);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,9)=="delsurvey")
{
$iVid = $_REQUEST['sid'];
//$sMod = $_REQUEST['mod'];
try
{
$sReturn = $client->sDeleteSurvey($user, $pass, $iVid);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,9)=="impMatrix")
{
$iVid = $_REQUEST['sid'];
// $sMod = $_REQUEST['mod'];
// $qTitle = $_REQUEST['title'];
$qText = $_REQUEST['quest'];
$mandatory = $_REQUEST['mandatory'];
for($n=1;$n<10;++$n)
{
if($_REQUEST['item'.$n]!='')
{
if($n==1)
{
$items = $_REQUEST['item'.$n];
}
else
{
$items .= ",".$_REQUEST['item'.$n];
}
}
}
$qHelp = $_REQUEST['help'];
try
{
$sReturn = $client->sImportMatrix($user, $pass, $iVid, $qTitle, $qText, $qHelp, $items, "Matrix5", $mandatory);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,8)=="impQuest")
{
$iVid = $_REQUEST['sid'];
// $sMod = $_REQUEST['mod'];
$qTitle = $_REQUEST['title'];
$qText = $_REQUEST['quest'];
$qHelp = $_REQUEST['help'];
$mandatory = $_REQUEST['mandatory'];
try
{
$sReturn = $client->sImportFreetext($user, $pass, $iVid, $qTitle, $qText, $qHelp, "Freitext", $mandatory);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,8)=="impGroup")
{
$iVid = $_REQUEST['sid'];
$sMod = $_REQUEST['mod'];
$sGroupName = $_REQUEST['groupName'];
$sGroupDescription = $_REQUEST['groupDescription'];
try
{
$sReturn = $client->sImportGroup($user, $pass, $iVid, $sMod, $sGroupName, $sGroupDescription);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,8)=="activate")
{
$iVid = $_REQUEST['sid'];
$dStart = $_REQUEST['start'];
$dEnd = $_REQUEST['end'];
if(isset($dStart) && $dStart!='')
{
$sUseStart='Y';
}
if(isset($dEnd) && $dEnd!='')
{
$sUseEnd='Y';
}
try
{
$sReturn = $client->sActivateSurvey($user, $pass, $iVid, $dStart, $dEnd);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,6)=="submit")
{
//$functionToCall = "sCreateSurvey";
$iVid = $_REQUEST['sid'];
$sVbes = $_REQUEST['sdes'];
$sVtit = $_REQUEST['stit'];
$sVwel = $_REQUEST['sVwel'];
$sVend = $_REQUEST['sVend'];
$sMail = $_REQUEST['sEmail'];
$sName = $_REQUEST['sName'];
$sUrl = $_REQUEST['sUrl'];
$sUbes = $_REQUEST['sUdes'];
$sVtyp = $_REQUEST['core'];
try
{
$sReturn = $client->sCreateSurvey($user, $pass, $iVid, $sVtit , $sVbes, $sVwel, $sVend, $sMail, $sName, $sUrl, $sUbes, $sVtyp);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,6)=="change")
{
$table = $_REQUEST['table'];
$key = $_REQUEST['key'];
$value = $_REQUEST['value'];
$where = $_REQUEST['whereKey'];
$mode = $_REQUEST['mode'];
//$whereValue = $_REQUEST['whereValue'];
try
{
$sReturn = $client->sChangeSurvey($user, $pass , $table, $key, $value, $where, $mode);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,6)=="tokens")
{
$sToken = $_REQUEST['token'];
try
{
$sReturn = $client->sInsertToken($user, $pass, $iVid, $sToken );
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//this are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
if(substr($key,0,6)=="tokRet")
{
//$functionToCall = "sTokenReturn";
try
{
$sReturn = $client->sTokenReturn($user, $pass, $iVid);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//this are the return Values
$sOutput .= "<br/><br/><b>Return</b>: <br/> ['return'] => ". $sReturn;
}
if(substr($key,0,6)=="insPar")
{
$sParticipantData = $_REQUEST['sParticipantData'];
try
{
$sReturn = $client->sInsertParticipants($user, $pass, $iVid, $sParticipantData);
}
catch (SoapFault $fault)
{
$sOutput .= " <br/><br/><b>SOAP Error: ".$fault->faultcode." : ".$fault->faultstring."</b>";
}
//these are just outputs for testing
$sOutput .= "<br/><br/><b>Return</b>: ". $sReturn;
}
}
if(isset($sReturn))
{
$sOutput .="<br/><br/>Dumping <b>request headers</b>:<br/><pre>"
.$client->__getLastRequestHeaders()."</pre>";
$sOutput .="Dumping <b>request</b>:<code>".htmlentities($client->__getLastRequest())."</code>";
$sOutput .="<br/><br/><br/> Dumping <b>response headers</b>:<br/><pre>"
.$client->__getLastResponseHeaders()."</pre>";
$sOutput .="<br/>Dumping <b>response</b>:<br/><code>".htmlentities($client->__getLastResponse())."</code>";
//$resp[] = $client->__getLastResponse();
// echo $resp['resParam'];
}
?>
</head>
<body>
<?php echo soapCheck($wsdl); ?>
<?php
// we dump the client object functions (which are functions of the server defined in the wsdl)
if(!isset($sOutput))
{
echo "<b>Client object functions:</b> <font style='font-size:x-small'>(As given in the wsdl file. Functions could be disabled or else on the serverside. There is no guarantee the functions really have these Params nor that the functions exist on the serverside.)</font><br/>";
if($file!=FALSE)
{
$funcs=$client->__getFunctions();
foreach($funcs as $func)
{
echo '<p><font style="font-family:tahoma, arial;font-size:small;" >';
print_r($func);
echo '</font></p>';
}
}
}
if(isset($sOutput))
{
echo '<div style="color:white;background-color:black;border: 1px solid white;">';
echo '<h3>testing output:</h3>';
if(isset($iVid))
{
echo "<a href='{$limeUrl}/index.php?sid=".$iVid."&amp;lang=de&amp;newtest=Y' target='_blank'>test Survey</a>";
}
echo $sOutput;
echo '</div>';
}
?>
<div style='margin-bottom: 5px'>
<h3>sCreateSurvey function</h3>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'>
<b><font color='red'>* </font>VeranstaltungsTyp:</b>
<br />
<select name='core' size='1'>
<?php
$aCores = explode(",", $cores);
for($n=0;$n<count($aCores);++$n)
{echo "<option value='".$aCores[$n]."'>".$aCores[$n]."</option>";}
?>
</select> <? //print_r($cores);?> <br />
<b><font color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b>
<br />
<input type='text' name='sid' size='8' maxlength='11' /> <br />
<b><font color='red'>* </font>Veranstaltungs Titel / Survey Title (used
as part of the welcome message, if welcome Message is left blank):</b> <br />
<input type='text' name='stit' size='30' maxlength='150' /> <br />
<b><font color='red'>* </font>VeranstaltungsBeschreibung /
SurveyDescription (used as part of the welcome message, if welcome
Message is left blank):</b> <br />
<input type='text' name='sdes' size='30' maxlength='150' /> <br />
<b>Willkommenstext / Welcome Message:</b> <br />
<textarea name='sVwel' cols='50' rows='3'></textarea> <br />
<b>Endtext / endtext:</b> <br />
<textarea name='sVend' cols='50' rows='3'></textarea> <br />
<b>Admin Name:</b> <br />
<input type='text' name='sName' size='30' maxlength='150' /> <br />
<b>Admin Email:</b> <br />
<input type='text' name='sEmail' size='30' maxlength='150' /> <br />
<b>End Url:</b> <br />
<input type='text' name='sUrl' size='30' maxlength='150' /> <br />
<b>Url Description:</b> <br />
<input type='text' name='sUdes' size='30' maxlength='150' /> <br />
<?php echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />" ?>
<input type='submit' name='submit' value='Create Survey!' /></form>
</div>
<div style='float: left; margin-bottom: 5px'>
<h3>sActivateSurvey function</h3>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'><b><font
color='red'>* </font>VeranstaltungsID / SurveyID:</b>
<br />
<input type='text' name='sid' size='5' maxlength='5'
value='<?php echo $iVid ?>' /> <br />
<b>Startdate (YYYY-MM-DD):</b> <br />
<input type='text' name='start' size='30' maxlength='150' /> <br />
<b>Enddate (YYYY-MM-DD):</b> <br />
<input type='text' name='end' size='30' maxlength='150' /> <br />
<?php echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />" ?>
<input type='submit' name='activate' value='Start Survey!' /></form>
</div>
<div style='float: left; margin-bottom: 5px; margin-left: 5px'>
<h3>sDeleteSurvey function</h3>(attention: no safetyquestion is asked!)<br/>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'><b><font
color='red'>* </font>VeranstaltungsID / SurveyID:</b>
<br />
<input type='text' name='sid' size='5' maxlength='5'
value='<?php echo $iVid ?>' /> <br />
<?php echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />" ?>
<input type='submit' name='delsurvey' value='Delete Survey!' /></form>
</div>
<div style='float: right; margin-bottom: 5px'>
<h3>sImportGroup function</h3>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'><b><font
color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b>
<br />
<input type='text' name='sid' size='5' maxlength='5'
value='<?php echo $iVid ?>' /> <br />
<b><font color='red'>* </font>Question group to add (INF,BIO,BWL is
there for testing):</b> <br />
<select name='mod' size='1'>
<?php
$aMods = explode(",", $mods);
for($n=0;$n<count($aMods);++$n)
{echo "<option value='".$aMods[$n]."'>".$aMods[$n]."</option>";}
?>
</select> <? //print_r($mods);?> <br />
<b>Name of the group:</b><br/>
<input type='text' name='groupName' size='30' maxlength='150' /> <br />
<b>groupDescription:</b><br/>
<input type='text' name='groupDescription' size='30' maxlength='255' /> <br />
<?php echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />" ?>
<input type='submit' name='impGroup' value='add group to survey!' /></form>
</div>
<div
style='clear: both; float: left; width: 49%; margin-bottom: 5px'>
<h3>sImportQuestion</h3>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'><b><font
color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b>
<br />
<input type='text' name='sid' size='5' maxlength='5'
value='<?php echo $iVid ?>' /> <br />
<input type='checkbox' name='mandatory' value='Y' /> Mandatory <br />
<b><font color='red'>* </font>Question Title :</b> <br />
<input type='text' name='title' size='30' maxlength='150' /> <br />
<b><font color='red'>* </font>Question:</b> <br />
<textarea name='quest' cols='50' rows='3'></textarea> <br />
<b>Helptext:</b> <br />
<textarea name='help' cols='50' rows='3'></textarea> <br />
<?php echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />" ?>
<input type='submit' name='impQuest' value='Create Question!' /></form>
</div>
<div
style='float: right; width: 49%; margin-bottom: 5px'>
<h3>sImportMatrix</h3>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'><b><font
color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b>
<br />
<input type='text' name='sid' size='5' maxlength='5'
value='<?php echo $iVid ?>' /> <br />
<input type='checkbox' name='mandatory' value='Y' /> Mandatory <br />
<b><font color='red'>* </font>Question :</b> <br />
<textarea name='quest' cols='50' rows='3'></textarea> <br />
<?php
for($n=1;$n<10;++$n)
{
echo "<b>Item {$n} :</b> <br />",
"<input type='text' name='item{$n}' size='50' maxlength='150'/>",
"<br />";
}
?> <b>Helptext:</b> <br />
<textarea name='help' cols='50' rows='3'></textarea> <br />
<?php echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />" ?>
<input type='submit' name='impMatrix' value='Create Question!' /></form>
</div>
<div style='float: left; margin-bottom: 5px'>
<h3>sChangeSurvey function</h3>
( this is not part of the lsrc, it just shows the power of it, <br/>it has to be activated in server.php on line ~60 )
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method='post'>
<input type="radio" name="mode" value="0" checked='checked' /> update
<input type="radio" name="mode" value="1" /> insert<br/>
<b>Table to change</b> <br />
<input type='text' name='table' size='30' maxlength='150' /> <br />
<b>Key</b><br />
<input type='text' name='key' size='30' maxlength='150' value='' /> <br />
<b>Value</b> <br />
<input type='text' name='value' size='30' maxlength='150' value='' /> <br />
<b>where Condition</b> <br />
<input type='text' name='whereKey' size='30' maxlength='150' /> <br />
<!-- <b>where Value</b> <br />
<input type='text' name='whereValue' size='30' maxlength='150'/>
<?php echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />" ?>
<br />--> <input type='submit' name='change' value='Change Survey!' /></form>
</div>
<div style='float:left;margin-bottom:5px'>
<?php
echo "<h3>sInsertToken function</h3>";
echo "<p>Makes the Survey closed.<br/> Means: It's only available to people who have an unused token</p>";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
echo "<b><font color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b> <br />";
echo "<input type='text' name='sid' size='5' maxlength='5' value='".$iVid."'/>";
echo "<br />";
echo "<b>Tokens seperated by comma (,) :</b> <br />";
echo "<input type='text' name='token' size='50' maxlength='110'/>";
echo "<br />";
echo "<input type='submit' name='tokens' value='Insert Token!'/>";
echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />";
echo "</form>";
echo "</div>";
echo "<div style='float:right; margin-bottom:5px'>";
echo "<h3>sTokenReturn function</h3>";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
echo "<b><font color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b> <br />";
echo "<input type='text' name='sid' value='".$iVid."' maxlength='5'/><br />";
echo "<input type='submit' name='tokRet' value='Check for unused Tokens!'/>";
echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />";
echo "</form></div>";
echo "<div style='clear:both;margin-bottom:5px'>";
echo "<h3>sInsertParticipants function</h3>";
echo "<p>Makes the Survey closed. Means: It's only available to people who have an unused token</p>";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
echo "<b><font color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b> <br />";
echo "<input type='text' name='sid' size='5' maxlength='5' value='".$iVid."'/>";
echo "<br />";
echo "<b><font color='red'>* </font>Data in this Format [params in square brackets are optional]:<br/> \"FIRSTNAME;LASTNAME;EMAIL[;[ATTRIB1];[ATTRIB2]]::FIRSTNAME;LASTNAME;EMAIL[;[ATTRIB1];[ATTRIB2]]\" and so on :</b> <br />";
echo "<textarea name='sParticipantData' cols='50' rows='3'>";
echo "</textarea> ";
echo "<br />";
echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />";
echo "<input type='submit' name='insPar' value='Insert Personal Data!'/>";
echo "</form>";
echo "</div>";
echo "<div style='clear:both;margin-bottom:5px'>";
echo "<h3>sSendEmail function</h3>";
echo "<p>Sends an Email to users of a specific survey. Invite, Remind and custom emails are possible</p>";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
echo "<b><font color='red'>* </font>SurveyID (have to be Integer):</b> <br />";
echo "<input type='text' name='sid' size='5' maxlength='5' value='".$iVid."'/>";
echo "<br />";
echo "<font color='red'>* </font><b> Email Type:</b><br/>";
echo "<input type='radio' name='type' value='invite' checked='checked' /> invite";
echo "<input type='radio' name='type' value='remind' /> remind";
echo "<input type='radio' name='type' value='custom' /> custom<br/>";
echo "<b>Maxemails (have to be Integer):</b> <br />";
echo "<input type='text' name='maxemails' size='5' maxlength='5' value=''/>";
echo "<br />";
//echo "<b><font color='red'>* </font>Data in this Format [params in square brackets are optional]:<br/> \"FIRSTNAME;LASTNAME;EMAIL[;[ATTRIB1];[ATTRIB2]]::FIRSTNAME;LASTNAME;EMAIL[;[ATTRIB1];[ATTRIB2]]\" and so on :</b> <br />";
echo "<b>Subject for custom cails</b> <br />";
echo "<input type='text' name='subject' size='50' maxlength='255' value=''/><br/>";
echo "<b>Mailtext for custom cails</b> <br />";
echo "<textarea name='mailText' cols='50' rows='3'>";
echo "</textarea> ";
echo "<br />";
echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />";
echo "<input type='submit' name='sendMail' value='Send Email to participants'/>";
echo "</form>";
echo "</div>";
echo "<div style='float:right; margin-bottom:5px'>";
echo "<h3>sGetFieldmap function</h3>";
echo "<p>Gets you the fieldmap from a survey as csv</p>";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>";
echo "<b><font color='red'>* </font>VeranstaltungsID / SurveyID (have to be Integer):</b> <br />";
echo "<input type='text' name='sid' value='".$iVid."' maxlength='5'/><br />";
echo "<input type='submit' name='getField' value='Get me the Fieldmap as CSV!'/>";
echo "<input type='hidden' name='wsdl' size='97' value='".$wsdl."' />";
echo "</form></div>";
//phpinfo();
?>
</body>
</html>

View File

@@ -0,0 +1,606 @@
<?xml version="1.0" encoding="utf-8"?>
<definitions name="LsrcService" targetNamespace="urn:lsrcNamespace"
xmlns:tns="urn:lsrcNamespace" xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:typens="lsrcSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:lsrcNamespace">
<xsd:element name="string" type="xsd:string"></xsd:element>
</xsd:schema>
</types>
<message name="sCreateSurveyRequest">
<documentation>Function to start Surveys in LimeSurvey...
</documentation>
<part name="sUser" type="xsd:string">
<documentation>Admin or Superadmin Account in Limesurvey needed
</documentation>
</part>
<part name="sPass" type="xsd:string">
<documentation>Correct password for the Superadmin in
Limesurvey
</documentation>
</part>
<part name="iVid" type="xsd:int">
<documentation>This is the &quot;VeranstaltungsID&quot; similar to the SurveyID... Integer expected... </documentation>
</part>
<part name="sVtit" type="xsd:string">
<documentation>titel of the event, put together from NR and NAME from LSF. veranstaltung</documentation></part>
<part name="sVbes" type="xsd:string" >
<documentation>This is the &quot;Veranstaltungsbeschreibung&quot;, the Surveydescription.
String expected. Put together from TYP, DOZENTEN- TITLE, -NAME,
</documentation>
</part>
<part name="sVwel" type="xsd:string"></part>
<part name="sVend" type="xsd:string"></part>
<part name="sMail" type="xsd:string"><documentation>The E-Mail Adress of the Person who to contact in matters of evaluation. Limesurvey uses this to send notifications of Surveyparticipation, if wante</documentation></part>
<part name="sName" type="xsd:string"><documentation>The Name of the Administrator, resp. the Person whos email Adress was given
</documentation></part>
<part name="sUrl" type="xsd:string"><documentation>The URL to wich will be redirected when completing the Survey
</documentation></part>
<part name="sUbes" type="xsd:string"><documentation>The text for the Link, if not loaded automatically</documentation></part>
<part name="sVtyp" type="xsd:string"></part>
<part name="sAutoRd" type="xsd:string"></part>
</message>
<message name="sCreateSurveyResponse">
<part name="vid" type="xsd:string">
<documentation>This is the return Value of sCreateSurvey, if everything went fine it's the sid(SurveyID) resp. vid(VeranstaltungsID) of the newly imported Survey
</documentation>
</part>
</message>
<message name="sInsertTokenRequest">
<part name="sUser" type="xsd:string">
<documentation>Admin or Superadmin Account in Limesurvey needed
</documentation>
</part>
<part name="sPass" type="xsd:string">
<documentation>Correct password for the Superadmin in Limesurvey
</documentation>
</part>
<part name="iVid" type="xsd:int">
<documentation>SurveyID of existing Survey, which gets the Token table
</documentation>
</part>
<part name="sToken" type="xsd:string">
<documentation>String of tokens seperated by a comma (default)... You have the possibility to change the desired seperator in LimeSurveys config.php
</documentation>
</part>
</message>
<message name="sInsertTokenResponse">
<part name="return" type="xsd:string" >
<documentation>This is the return Value of InsertToken, if everything went fine it's "Token table populated successfully"
</documentation>
</part>
</message>
<message name="sInsertParticipantsRequest">
<part name="sUser" type="xsd:string">
<documentation>Admin or Superadmin Account in Limesurvey needed
</documentation>
</part>
<part name="sPass" type="xsd:string">
<documentation>Correct password for the Superadmin in Limesurvey
</documentation>
</part>
<part name="iVid" type="xsd:int">
<documentation>SurveyID of existing Survey, which gets the Token table
</documentation>
</part>
<part name="sParticipantData" type="xsd:string">
<documentation>Data for Participant expected in this format: [Firstname];[Lastname];[email@email.de]::[Firstname];[Lastname];[email@email.de]::[Firstname];[Lastname];[email@email.de] and so on... seperate the Datasets with :: and the Datafields in the Sets with ;
</documentation>
</part>
</message>
<message name="sInsertParticipantsResponse">
<part name="return" type="xsd:string" >
<documentation>This is the return Value of sInsertParticipants, if everything went fine it's "Token table populated successfully"
</documentation>
</part>
</message>
<message name="sTokenReturnRequest">
<part name="sUser" type="xsd:string">
<documentation>Admin or Superadmin Account in Limesurvey needed
</documentation>
</part>
<part name="sPass" type="xsd:string">
<documentation>Correct password for the Superadmin in Limesurvey
</documentation>
</part>
<part name="iVid" type="xsd:int">
<documentation>SurveyID of existing Survey, which has a Token table
</documentation>
</part>
</message>
<message name="sTokenReturnResponse">
<part name="return" type="xsd:string" >
<documentation>String of unused Tokens seperated by comma
</documentation>
</part>
</message>
<message name="sCreateSurveyFault">
<part name="fault" element="xsd:string" />
</message>
<message name="sInsertTokenFault">
<part name="fault" element="xsd:string" />
</message>
<message name="sInsertParticipantsFault">
<part name="fault" element="xsd:string" />
</message>
<message name="sTokenReturnFault">
<part name="fault" element="xsd:string" />
</message>
<message name="sChangeSurveyRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="sTable" type="xsd:string"></part>
<part name="sKey" type="xsd:string"></part>
<part name="sValue" type="xsd:string"></part>
<part name="sWhere" type="xsd:string"></part>
<part name="mode" type="xsd:string"></part>
</message>
<message name="sChangeSurveyResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sChangeSurveyFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sActivateSurveyRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="dStart" type="xsd:date"></part>
<part name="dEnd" type="xsd:date"></part>
</message>
<message name="sActivateSurveyResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sActivateSurveyFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sImportGroupRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="sMod" type="xsd:string"></part>
<part name="sGroupName" type="xsd:string"></part>
<part name="sGroupDescription" type="xsd:string"></part>
</message>
<message name="sImportGroupResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sImportGroupFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sImportQuestionRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="sMod" type="xsd:string"></part>
<part name="sMandatory" type="xsd:string"></part>
</message>
<message name="sImportQuestionResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sImportQuestionFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sAvailableModulesRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="mode" type="xsd:string"></part>
</message>
<message name="sAvailableModulesResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sAvailableModulesFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sImportFreetextRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="sTitle" type="xsd:string"></part>
<part name="sQuestion" type="xsd:string"></part>
<part name="sHelp" type="xsd:string"></part>
<part name="sMod" type="xsd:string"></part>
<part name="sMandatory" type="xsd:string"></part>
</message>
<message name="sImportFreetextResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sImportFreetextFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sImportMatrixRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="sTitle" type="xsd:string"></part>
<part name="sQuestion" type="xsd:string"></part>
<part name="qHelp" type="xsd:string"></part>
<part name="sItems" type="xsd:string"></part>
<part name="sMod" type="xsd:string"></part>
<part name="sMandatory" type="xsd:string"></part>
</message>
<message name="sImportMatrixResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sImportMatrixFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sDeleteSurveyRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
</message>
<message name="sDeleteSurveyResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sDeleteSurveyFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sSendEmailRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
<part name="type" type="xsd:string"></part>
<part name="maxemails" type="xsd:int"></part>
<part name="subject" type="xsd:string"></part>
<part name="emailText" type="xsd:string"></part>
</message>
<message name="sSendEmailResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sSendEmailFault">
<part name="fault" element="xsd:string"></part>
</message>
<message name="sGetFieldmapRequest">
<part name="sUser" type="xsd:string"></part>
<part name="sPass" type="xsd:string"></part>
<part name="iVid" type="xsd:int"></part>
</message>
<message name="sGetFieldmapResponse">
<part name="return" type="xsd:string"></part>
</message>
<message name="sGetFieldmapFault">
<part name="fault" element="xsd:string"></part>
</message>
<portType name="LsrcPortType">
<operation name="sCreateSurvey" >
<documentation>Creates (Import and activate) a Survey in LimeSurvey</documentation>
<input name="sCreateSurveyRequest" message="tns:sCreateSurveyRequest" />
<output name="sCreateSurveyResponse" message="tns:sCreateSurveyResponse" />
<fault name="sCreateSurveyFault" message="tns:sCreateSurveyFault"/>
</operation>
<operation name="sInsertToken" >
<documentation>Create Token-Table and populate it for closed LimeSurvey Surveys</documentation>
<input name="sInsertTokenRequest" message="tns:sInsertTokenRequest" />
<output name="sInsertTokenResponse" message="tns:sInsertTokenResponse" />
<fault name="sInsertTokenFault" message="tns:sInsertTokenFault"/>
</operation>
<operation name="sInsertParticipants" >
<documentation>Create Token-Table and populate it with personal data for closed Surveys</documentation>
<input name="sInsertParticipantsRequest" message="tns:sInsertParticipantsRequest" />
<output name="sInsertParticipantsResponse" message="tns:sInsertParticipantsResponse" />
<fault name="sInsertParticipantsFault" message="tns:sInsertParticipantsFault"/>
</operation>
<operation name="sTokenReturn" >
<documentation>Returns unused Tokens from closed LimeSurvey Surveys</documentation>
<input name="sTokenReturnRequest" message="tns:sTokenReturnRequest" />
<output name="sTokenReturnResponse" message="tns:sTokenReturnResponse" />
<fault name="sTokenReturnFault" message="tns:sTokenReturnFault"/>
</operation>
<operation name="sChangeSurvey">
<input name="sChangeSurveyRequest" message="tns:sChangeSurveyRequest"></input>
<output name="sChangeSurveyResponse" message="tns:sChangeSurveyResponse"></output>
<fault name="sChangeSurveyFault" message="tns:sChangeSurveyFault"></fault>
</operation>
<operation name="sActivateSurvey">
<input name="sActivateSurveyRequest" message="tns:sActivateSurveyRequest"></input>
<output name="sActivateSurveyResponse" message="tns:sActivateSurveyResponse"></output>
<fault name="sActivateSurveyFault" message="tns:sActivateSurveyFault"></fault>
</operation>
<operation name="sImportGroup">
<input name="sImportGroupRequest" message="tns:sImportGroupRequest"></input>
<output name="sImportGroupResponse" message="tns:sImportGroupResponse"></output>
<fault name="sImportGroupFault" message="tns:sImportGroupFault"></fault>
</operation>
<operation name="sImportQuestion">
<input name="sImportQuestionRequest" message="tns:sImportQuestionRequest"></input>
<output name="sImportQuestionResponse" message="tns:sImportQuestionResponse"></output>
<fault name="sImportQuestionFault" message="tns:sImportQuestionFault"></fault>
</operation>
<operation name="sAvailableModules">
<input name="sAvailableModulesRequest" message="tns:sAvailableModulesRequest"></input>
<output name="sAvailableModulesResponse" message="tns:sAvailableModulesResponse"></output>
<fault name="sAvailableModulesFault" message="tns:sAvailableModulesFault"></fault>
</operation>
<operation name="sImportFreetext">
<input name="sImportFreetextRequest" message="tns:sImportFreetextRequest"></input>
<output name="sImportFreetextResponse" message="tns:sImportFreetextResponse"></output>
<fault name="sImportFreetextFault" message="tns:sImportFreetextFault"></fault>
</operation>
<operation name="sImportMatrix">
<input name="sImportMatrixRequest" message="tns:sImportMatrixRequest"></input>
<output name="sImportMatrixResponse" message="tns:sImportMatrixResponse"></output>
<fault name="sImportMatrixFault" message="tns:sImportMatrixFault"></fault>
</operation>
<operation name="sDeleteSurvey">
<input name="sDeleteSurveyRequest" message="tns:sDeleteSurveyRequest"></input>
<output name="sDeleteSurveyResponse" message="tns:sDeleteSurveyResponse"></output>
<fault name="sDeleteSurveyFault" message="tns:sDeleteSurveyFault"></fault>
</operation>
<operation name="sSendEmail">
<input name="sSendEmailRequest" message="tns:sSendEmailRequest"></input>
<output name="sSendEmailResponse" message="tns:sSendEmailResponse"></output>
<fault name="sSendEmailFault" message="tns:sSendEmailFault"></fault>
</operation>
<operation name="sGetFieldmap">
<input message="tns:sGetFieldmapRequest" name="sGetFieldmapRequest"></input>
<output message="tns:sGetFieldmapResponse" name="sGetFieldmapResponse"></output>
<fault name="sGetFieldmapFault" message="tns:sGetFieldmapFault"></fault>
</operation>
</portType>
<binding name="LsrcBinding" type="tns:LsrcPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="sGetFieldmap">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sGetFieldmapRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sGetFieldmapResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sGetFieldmapFault">
<soap:fault name="sGetFieldmapFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sSendEmail">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sSendEmailRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sSendEmailResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sSendEmailFault">
<soap:fault name="sDeleteSurveyFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sDeleteSurvey">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sDeleteSurveyRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sDeleteSurveyResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sDeleteSurveyFault">
<soap:fault name="sDeleteSurveyFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sImportMatrix">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sImportMatrixRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sImportMatrixResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sImportMatrixFault">
<soap:fault name="sImportMatrixFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sImportFreetext">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sImportFreetextRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sImportFreetextResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sImportFreetextFault">
<soap:fault name="sImportFreetextFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sImportQuestion">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sImportQuestionRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sImportQuestionResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sImportQuestionFault">
<soap:fault name="sImportQuestionFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sAvailableModules">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sAvailableModulesRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sAvailableModulesResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sAvailableModulesFault">
<soap:fault name="sAvailableModulesFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sImportGroup">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sImportGroupRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sImportGroupResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sImportGroupFault">
<soap:fault name="sImportGroupFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sActivateSurvey">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sActivateSurveyRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sActivateSurveyResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sActivateSurveyFault">
<soap:fault name="sActivateSurveyFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sChangeSurvey">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sChangeSurveyRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sChangeSurveyResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sChangeSurveyFault">
<soap:fault name="sChangeSurveyFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sCreateSurvey">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sCreateSurveyRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sCreateSurveyResponse">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sCreateSurveyFault">
<soap:fault name="sCreateSurveyFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sInsertToken">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sInsertTokenRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sInsertTokenResponse" >
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sInsertTokenFault">
<soap:fault name="sInsertTokenFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sInsertParticipants">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sInsertParticipantsRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sInsertParticipantsResponse" >
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sInsertParticipantsFault">
<soap:fault name="sInsertParticipantsFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
<operation name="sTokenReturn">
<soap:operation soapAction="urn:lsrcNamespaceAction" style="rpc" />
<input name="sTokenReturnRequest">
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="sTokenReturnResponse" >
<soap:body namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
<fault name="sTokenReturnFault">
<soap:fault name="sTokenReturnFault" namespace="urn:lsrcNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</fault>
</operation>
</binding>
<service name="LsrcService">
<documentation>This is the LsrcService
for remote starting surveys and registering tokens in LimeSurvey.

View File

@@ -0,0 +1,27 @@
# LimeSurvey Question Dump
# DBVersion 132
# This is a dumped question from the LimeSurvey Script
# http://www.limesurvey.org/
# Do not change this header!
#
# QUESTIONS TABLE
#
"qid","sid","gid","type","title","question","preg","help","other","mandatory","lid","lid1","question_order","language"
"2902","666","559","T","1","Placeholder","","Placeholder","N","Y","0","0","0","de"
#
# ANSWERS TABLE
#
#
# LABELSETS TABLE
#
#
# LABELS TABLE
#
#
# QUESTION_ATTRIBUTES TABLE
#
1 # LimeSurvey Question Dump
2 # DBVersion 132
3 # This is a dumped question from the LimeSurvey Script
4 # http://www.limesurvey.org/
5 # Do not change this header!
6 #
7 # QUESTIONS TABLE
8 #
9 qid sid gid type title question preg help other mandatory lid lid1 question_order language
10 2902 666 559 T 1 Placeholder Placeholder N Y 0 0 0 de
11 #
12 # ANSWERS TABLE
13 #
14 #
15 # LABELSETS TABLE
16 #
17 #
18 # LABELS TABLE
19 #
20 #
21 # QUESTION_ATTRIBUTES TABLE
22 #

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