TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 445
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 413
  • Total: 413

Help Installing a Script?

Started by SN, March 16, 2009, 12:06:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SN

Can any one help me out with getting this script to work with in a Block

Here's the Script i have got: http://www.dbscripts.net/poll/

I am using SMF 1.1.8 and TP v1.0 beta 3

I have uploaded the script to my server. It says its a PHP script but when i put it in a PHP block its doesn't work it only part of it shows up in a HTML/Java Black... but the Poll doesn't appear

It has an example code which was included and it looks like this

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Poll Test</title>
<link href="poll/template/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>Poll Test</h1>

<p>
This page is intended to demonstrate how you can quickly add 
polls to almost any page on your website.
</p>

<h2>Poll 1</h2>
<?php

// The two lines below are all that is required to add a poll 
// to your page.  Obviously, these need to be placed within  
// a PHP code block inside a valid PHP page.  You will also need to 
// configure the settings in config.php properly, where you will 
// also define your polls.
//  
// Modify these lines as follows: 
//
// * Change the include path to reflect where DRBPoll is installed.  
// * Change the parameter for show_vote_control() to reflect the unique  
//   ID for the poll on this page.  This feature allows you to store  
//   data for more than one poll using the same installation of DRBPoll.
//   New polls must be added to the $VALID_POLLS array in config.php. 

require_once('poll/poll.php');
show_vote_control('1');

// More than one poll can be displayed on the same page; here's 
// another example:
?>
<h2>Poll 2</h2><?php 
show_vote_control('2');

?>

</body>
</html>


And in the Readme file which was included it tell you to edit the Config file which is for the script to match your needs.

here's the config file

<?php
/****************************************************************************
 * DRBPoll
 * http://www.dbscripts.net/poll/
 * 
 * Copyright © 2007-2008 Don B 
 ****************************************************************************/

require_once(dirname(__FILE__) . '/class.php'); // For the Poll class definition

// Modify this string to reflect the URL where DRBPoll is installed.
// A trailing slash must be included.  This URL will be used in the generated 
// HTML for the URL for the form submission.  This may be a relative or 
// absolute URL.
$POLL_URL 'poll/';

// Names of the form input elements in the poll form.
// You probably won't need to change these unless the names conflict with some 
// other element on your pages.
$POLL_ID_PARAM_NAME "pollid";
$VOTE_PARAM_NAME "vote";

// Maximum width of a bar of the poll results, in pixels
// Change this if you want to make the poll bar chart larger 
// or smaller in width.
$MAX_POLL_BAR_WIDTH 200;

// Whether or not the script should prevent the same IP address 
// from voting multiple times on the same poll.
// Set to FALSE to allow duplicate votes.  
$PREVENT_DUPLICATE_VOTES TRUE;

// Whether or not vote counts should be displayed. 
// If set to FALSE, only the percentages will be shown.  
$SHOW_COUNTS TRUE;

// These are the strings that are displayed in the poll control 
// and the result page.
// Modify these to customize what is displayed to the user.
$SUBMIT_BUTTON_STRING 'Submit';
$NUMBER_OF_VOTES_STRING 'Total votes: %s';
$VOTE_STRING 'Vote:'; // Used as label for combobox control type
$VOTE_LIST_DEFAULT_LABEL 'Please Select'; // This is the "empty" option when using a combobox
$VIEW_RESULTS_STRING 'Current Results';
$DUPLICATE_VOTE_ERROR_MSG 'You have already voted!';
$NO_VOTE_SELECTED_ERROR_MSG 'You forgot to select a value!';

// List of valid polls.  All vote requests are checked against this list 
// to ensure that malicious users do not submit invalid poll IDs through a 
// cross-site request forgery.  
//
// Add or modify the $VALID_POLLS array to add, modify, or remove polls.   
// The key of the $VALID_POLLS associative array represents the poll ID; 
// this value must be a string.  In addition, it must only use alphanumeric 
// characters (A-Z, a-z, and 0-9).
//
// Set the question property of the Poll object to a string representing 
// the question to be displayed.
//
// Call add_value() on the Poll object to add a new value.  The first 
// parameter represents the value ID, which must be a alphanumeric string.  
// The second parameter is the string to display to the user for this value.

$VALID_POLLS = array(); // The keys of this associative array are the poll IDs

// First poll definition
$p = new Poll;
$p->question "What is your favorite color?"; // Question displayed to the user
$p->returnToURL "../example.php"; // Specify the URL to return to for this poll; may be relative or absolute
$p->legend "First Poll"; // Form legend; leave empty for none
$p->control_type $CONTROL_RADIOBUTTONS; // Control type; $CONTROL_RADIOBUTTONS or $CONTROL_COMBOBOX
$p->add_value("1""Red"); // Poll value ID and a display string
$p->add_value("2""Green");
$p->add_value("3""Blue");
$p->add_value("4""Yellow");
$VALID_POLLS["1"] = $p; // "1" is the poll ID

// Second poll definition
$p = new Poll;
$p->question "How old are you?"; // Question displayed to the user
$p->returnToURL "../example.php"; // Specify the URL to return to for this poll; may be relative or absolute
$p->legend "Second Poll"; // Form legend; leave empty for none
$p->control_type $CONTROL_COMBOBOX; // Control type; $CONTROL_RADIOBUTTONS or $CONTROL_COMBOBOX
$p->add_value("1""0-15 years"); // Poll value ID and a display string
$p->add_value("2""16-20 years");
$p->add_value("3""21-30 years");
$p->add_value("4""31-40 years");
$p->add_value("5""41-50 years");
$p->add_value("6""50+ years");
$VALID_POLLS["2"] = $p; // "2" is the poll ID

?>


The first two steps of the readme file say

Quote1) Extract the ZIP file into the desired destination folder on your website.
   Optionally, you may rename the "poll" folder to whatever name is
   desired; you will need to change the POLL_URL variable in config.php,
   and the include path in example.php to reflect this change.

2) Modify the settings in config.php to match your environment and desired
   configuration.  This is where you will define your polls; some example
   polls are included for reference.  Detailed descriptions of the settings
   are included in the comments within that file.

and im not sure where i have to edit the Config file, if someone could point out all the places i have to edit that would be great

at the moment the script is uploaded to my Sites Root directory (i.e http://mysite.com/poll) and not my forum directory (i.e http://mysite.com/Forums/...) Im not sure if that is where my problems lies. But at the moment i can't even get the Poll to appear in a block.

Im not sure if you need any more information to help me, if you do please let me know

stormlrd

What is the actual code your putting in the block? If your putting mixed html and php in a php block thats not gonna work and your sample code is mixed. Also yes you'll have to put your files in the root of your forum and follow the directions for configuring it there.

in your sample everything between the <?php and closing ?> is what goes in the php block without the <?php and closing ?> this is already done. What will happen if you put all of that in a block as is, is what your getting "nothing" lol it will read the error and not generate the block for you.

Lesmond

#2
Exactly has StormLrd™ says so all you have is the code below in a php block, not tested but give it a go

require_once('poll/poll.php');
show_vote_control('1');

echo '<h2>Poll 2</h2>';
show_vote_control('2');

stormlrd

#3
omit this as well:

// More than one poll can be displayed on the same page; here's
   // another example:
   ?><h2>Poll 2</h2><?php
   show_vote_control('2');

You don't want to close and open php tags in a php block

or change it to this:

echo '<h2>Poll 2</h2>';
show_vote_control('2');

the actual
show_vote_control('2');
calls the poll function

Lesmond

Thanks StormLrdâ„¢ I missed that bit lol

SN

#5
Ok thanks for the fast replys.

So re install the Script to the forums root

there a few things i don't understand about the Config file.

$POLL_URL = 'poll/';

through out the config files, parts of the code shows up red and blue like above.

What part do i edit, the red or the blue?

for example

$POLL_URL = 'http://mysite/forums/poll/';

or

$http://mysite/forums/ = 'poll/';

stormlrd

lol oh boy... your phrasing indicates the need for some lessons in php ;)

$POLL_URL = 'http://mysite/forums/poll/';

you change the mysite/forums/poll/ to where you have the file located in your directory.

RED or BLUE I can't say its that simple, the way this looks like it works is your building arrays 1,2,3,etc each one representing a poll and its choices, your gonna have to play with it to learn how it works to be honest. The first step for YOU is to get the sample working as is, that way you know you have a working position to fall back on when you make errors and you will make them until you get the hang of it. So don't get discouraged

SN

Yeah i know i need to learn abit more about php Haha... im just starting out this is my first site...

but thanks for your help

stormlrd

your welcome besure to post a link to your site once you get it working be nice to see it in action and good luck

This website is proudly hosted on Crocweb Cloud Website Hosting.