vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Horoscope: Why won't it work? (https://vborg.vbsupport.ru/showthread.php?t=96977)

Brent H 09-27-2005 12:35 AM

Horoscope: Why won't it work?
 
I'm trying to port over the horoscope hack (for my own personal use, not releasing it as I don't have permission), and everything is fine except I can't figure out why it's not reading from the database correctly.

I've got the cron working correctly and the data is sitting there in the database, but zodiac.php just isn't reading it correctly. Here's zodiac.php:

PHP Code:

<?php
/*******************************************\
*    Zodiac v1.0.3            [zodiac.php]    *
*********************************************
*    Created by Steve    For use with VB3    *
*********************************************
*  Zodiac and Horoscope Addon for VBulletin    *
\*******************************************/

/* Define Stuff */
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''zodiac');
$phrasegroups = array();
$specialtemplates = array();
$actiontemplates = array();
$globaltemplates = array('zodiac_main');
require_once(
'./global.php');
require_once(
'./includes/functions_user.php');
$hackname="Zodiac Horoscope";
$horoscopetype="Weekly Horoscope";

/* Set Navigation */
if (isset($_GET['do'])) {
    
$do $_GET['do'];
}

/* Stuff */
if ($do=="aries") {
    
// Aries
    
$title="Aries";
    
$horoscope=$vbulletin->db->query("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="taurus") {
    
// Taurus
    
$title="Taurus";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="gemini") {
    
// Gemini
    
$title="Gemini";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="cancer") {
    
// Cancer
    
$title="Cancer";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="leo") {
    
// Leo
    
$title="Leo";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="virgo") {
    
// Virgo
    
$title="Virgo";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="libra") {
    
// Libra
    
$title="Libra";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="scorpio") {
    
// Scorpio
    
$title="Scorpio";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="sagittarius") {
    
// Sagittarius
    
$title="Sagittarius";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="capricorn") {
    
// Capricorn
    
$title="Capricorn";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="aquarius") {
    
// Aquarius
    
$title="Aquarius";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} elseif (
$do=="pisces") {
    
// Pisces
    
$title="Pisces";
    
$horoscope=$vbulletin->db->query_read("SELECT weekly FROM " TABLE_PREFIX "zodiac WHERE sign='".$do."'");
} else {
    
// None
    
$title="Zodiac Horoscope";
    
$horoscope[weekly]="To view a weekly horoscope please select a zodiac from the following list:<br><li><a href=\"?do=aries\">Aries</a></li> <li><a href=\"?do=taurus\">Taurus</a></li> <li><a href=\"?do=gemini\">Gemini</a></li> <li><a href=\"?do=cancer\">Cancer</a></li> <li><a href=\"?do=leo\">Leo</a></li> <li><a href=\"?do=virgo\">Virgo</a></li> <li><a href=\"?do=libra\">Libra</a></li> <li><a href=\"?do=scorpio\">Scorpio</a></li> <li><a href=\"?do=sagittarius\">Sagittarius</a></li> <li><a href=\"?do=capricorn\">Capricorn</a></li> <li><a href=\"?do=aquarius\">Aquarius</a></li> <li><a href=\"?do=pisces\">Pisces</a></li><br>Thanks.";
}

// Please Do Not alter, remove or make invisible the footer as it is part of the free horoscope feed arrangement
$hackfooter="Powered by: <a href=\"http://hop.clickbank.net/?juseste/branch90\" target=\"_blank\">Astrology Source</a>";

/* Display */
$horoscope=("$horoscope[weekly]");
if (
$horoscope=="") { $horoscope="There appears to be a problem with the Database.<br>The $do weekly horoscope can't be retrieved at this time.<br>Please check back later.<br><b>Thankyou</b>."; }
eval(
'print_output("' fetch_template('zodiac_main') . '");');

?>

Thanks for your help

Paul M 09-27-2005 12:50 AM

Ugh, what a horrible set of if's

What do you mean by "but zodiac.php just isn't reading it correctly" - what result do you get exactly ?

Brent H 09-27-2005 01:01 AM

1 Attachment(s)
Sorry for being vague LOL, PHP isn't my strong point ;)

The page is supposed to display a list of Zodiac signs, which it does. When I click on one of them, say "Capricorn" (zodiac.php?do=capricorn) it gives me:
"There appears to be a problem with the database. The capricorn weekly horoscope can't be retrieved at this time. Please check back later."

The data is in the table though, I'm looking at it right now. (screenshot attached)

Here's a link to the original zodiac hack.

If it matters, this is the install code I'm using for the vBulletin product:
PHP Code:

$db->query_write"CREATE TABLE `".TABLE_PREFIX."zodiac` (
        `sign` VARCHAR(12) NOT NULL,
        `weekly` LONGTEXT NOT NULL
        ) TYPE=MyISAM;"
);

$db->query_write("INSERT INTO `".TABLE_PREFIX."zodiac` (`sign`, `weekly`) VALUES ('aries', ''), ('taurus', ''), ('gemini', ''), ('cancer', ''), ('leo', ''), ('virgo', ''), ('libra', ''), ('scorpio', ''), ('sagittarius', ''), ('capricorn', ''), ('aquarius', ''), ('pisces', '');"); 

Again, thanks for your help.

Paul M 09-27-2005 01:18 AM

above the line /* Stuff */ add a temp line that says ;

Code:

echo "DO = ".$do; exit;
then run it and report the result.

Brent H 09-27-2005 01:22 AM

It just says "DO = "

Paul M 09-27-2005 01:34 AM

Thought it might;

try this test ;

Code:

echo "DO = ".$vbulletin->GPC['do']; exit;

Brent H 09-27-2005 01:37 AM

Same exact thing, LOL
"DO = "

Paul M 09-27-2005 01:41 AM

Yeah, i'm sure 3.5 does some processing with the POST & GET variables now as part of loading global.php, but I can't remember exactly what, and I don't have the code in front of me.

You can probably fudge it by moving

PHP Code:

/* Set Navigation */ 
if (isset($_GET['do'])) { 
    
$do $_GET['do']; 


above the

PHP Code:

require_once('./global.php'); 
require_once(
'./includes/functions_user.php'); 


Brent H 09-27-2005 01:52 AM

Moving the code like you suggested results in a blank page, so that method won't work I guess :(

Thank you so much for your help so far though, Paul. It's very much appreciated.

Paul M 09-27-2005 02:05 AM

Quote:

Originally Posted by TheHeggy
Moving the code like you suggested results in a blank page, so that method won't work I guess :(

I don't see how it could do that, you did remove the temp echo & exit ?

Anyway, from memory, in the original code posted above, try changing

PHP Code:

if (isset($_GET['do'])) { 
    
$do $_GET['do']; 


to

PHP Code:

if (isset($_REQUEST['do'])) { 
    
$do $_REQUEST['do']; 


Also, I notice that in your conversion from the original, you have changed all the query_first to query_read - (except one where you just have query) - you don't need to do this and should probably change them back as you only need the first result.


All times are GMT. The time now is 03:31 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01354 seconds
  • Memory Usage 1,794KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (6)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete