83 |
$sql="update '.$poll.' set '.join(",\n",@sql_update).', |
$sql="update '.$poll.' set '.join(",\n",@sql_update).', |
84 |
do_stranice=\'$PHP_SELF\' |
do_stranice=\'$PHP_SELF\' |
85 |
where id=$id"; |
where id=$id"; |
86 |
print "<pre>$sql</pre>"; |
# print "<pre>$sql</pre>"; |
87 |
$result=pg_Exec($conn,fix_sql($sql)); |
$result=pg_Exec($conn,fix_sql($sql)); |
88 |
} elseif($do_stranice != $PHP_SELF && isset($do_uri) && isset($a)) { |
} elseif($do_stranice != $PHP_SELF && isset($do_uri) && isset($a)) { |
89 |
Header("Location: $do_uri?a=$a"); |
Header("Location: $do_uri?a=$a"); |
179 |
print "p[$page_nr] "; |
print "p[$page_nr] "; |
180 |
|
|
181 |
open(PAGE, ">$poll/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
open(PAGE, ">$poll/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
|
if ($page_nr <= 2) { |
|
|
print PAGE php_new_poll(); |
|
|
} |
|
182 |
print PAGE php_header($page_nr,@prelast_sql_update); |
print PAGE php_header($page_nr,@prelast_sql_update); |
183 |
my $next_fn=sprintf("%02d.php",$page_nr); |
my $next_fn=sprintf("%02d.php",$page_nr); |
184 |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
194 |
# dump sql structure |
# dump sql structure |
195 |
|
|
196 |
open(SQL,">$poll/$poll.sql") || die "$poll.sql: $!"; |
open(SQL,">$poll/$poll.sql") || die "$poll.sql: $!"; |
197 |
|
print SQL "drop database ".$prefix.$poll.";\n"; |
198 |
|
print SQL "create database ".$prefix.$poll.";\n"; |
199 |
|
print SQL "\\connect ".$prefix.$poll.";\n"; |
200 |
print SQL "create table poslani ( member_id int4 not null, unesen timestamp default now() );\n"; |
print SQL "create table poslani ( member_id int4 not null, unesen timestamp default now() );\n"; |
201 |
print SQL "create table $poll (do_stranice text default null, ",join(",\n",@sql_create),");\n"; |
print SQL "create table $poll (do_stranice text default null, ",join(",\n",@sql_create),");\n"; |
202 |
close(SQL); |
close(SQL); |
232 |
|
|
233 |
# return unique name of pitanje |
# return unique name of pitanje |
234 |
sub new_pit { |
sub new_pit { |
235 |
my $out="p".$pitanje_nr.$p_suffix; |
my $out="p".$pitanje_nr; |
236 |
|
$out .= "_".$p_suffix if ($p_suffix); |
237 |
$curr_suffix=$p_suffix; |
$curr_suffix=$p_suffix; |
238 |
$p_suffix++; |
$p_suffix++; |
239 |
return $out; |
return $out; |
439 |
} # End sgml_escape |
} # End sgml_escape |
440 |
|
|
441 |
|
|
|
sub php_new_poll { |
|
|
return '<?php |
|
|
include_once("common.php"); |
|
|
if (isset($do_stranice) && $do_stranice !="") { |
|
|
Header("Location: $do_uri?a=$a"); |
|
|
exit; |
|
|
} |
|
|
$member_id=id_decode($a); |
|
|
$sql="insert into '.$poll.' ( http_referer,remote_addr,user_agent, member_id ) values (\'$HTTP_REFERER\',\'$REMOTE_ADDR\',\'$HTTP_USER_AGENT\',$member_id)"; |
|
|
|
|
|
# print "<pre>$sql</pre>"; |
|
|
$result=pg_Exec($conn,fix_sql($sql)); |
|
|
$lastoid=pg_getlastoid($result); |
|
|
$result = pg_Exec($conn,fix_sql("select id from '.$poll.' where oid=$lastoid")); |
|
|
$row=pg_fetch_row($result,0); |
|
|
$id=$row[0]; |
|
|
?>'; |
|
|
} |
|
|
|
|
442 |
################################################################ |
################################################################ |
443 |
|
|
444 |
package Poll; |
package Poll; |
457 |
|
|
458 |
if (defined $last_fn) { |
if (defined $last_fn) { |
459 |
open(PAGE, ">$poll/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
open(PAGE, ">$poll/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
460 |
if ($page_nr < 2) { |
print PAGE php_header($page_nr,@prelast_sql_update); |
|
print PAGE php_new_poll(); |
|
|
} else { |
|
|
print PAGE php_header($page_nr,@prelast_sql_update); |
|
|
} # last_sql_update |
|
|
|
|
|
|
|
461 |
my $next_fn=sprintf("%02d.php",$page_nr); |
my $next_fn=sprintf("%02d.php",$page_nr); |
462 |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
463 |
print PAGE $last_page; |
print PAGE $last_page; |
747 |
} |
} |
748 |
} |
} |
749 |
|
|
750 |
|
print "\n\nTo create database for poll $poll use:\n\n"; |
751 |
|
print "\$ psql template1 < $poll/$poll.sql\n\n"; |
752 |
|
print "THIS WILL DISTROY ALL DATA IN EXISTING DATABASE ".$prefix.$poll." !!\n"; |
753 |
|
|
754 |
# read configuration data |
# read configuration data |
755 |
# |
# |
756 |
# FIX: write actually this :-) |
# FIX: write actually this :-) |