Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 02-26-2012, 06:50 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...I threw together a test page based on your script and it seems to work. I'll post it in case it helps you somehow:

PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################

error_reporting(E_ALL & ~E_NOTICE);



// #################### DEFINE IMPORTANT CONSTANTS #######################



define('THIS_SCRIPT''Googlesearch');

define('CSRF_PROTECTION'true);

// change this depending on your filename



// ################### PRE-CACHE TEMPLATES AND DATA ######################

// get special phrase groups

$phrasegroups = array();



// get special data templates from the datastore

$specialtemplates = array();



// pre-cache templates used by all actions

$globaltemplates = array();



// pre-cache templates used by specific actions

$actiontemplates = array();



// ######################### REQUIRE BACK-END ############################

// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line

// chdir ('/path/to/your/forums');

require_once('./global.php');


if (
$_REQUEST['do'] == 'search')
{
if (
$_REQUEST['source'] == 0)
{
    
$vbulletin->url 'search.php?do=process&query=' urlencode($_REQUEST['q']);
    
print_standard_redirect(''false);
}
else
    echo 
'search google';

}
else
{
echo 
'<form action="test.php">
<input type="hidden" name="do" value="search">
<input type="text" name="q" size="20" /></br>
Midwifery Online <input type="radio" name="source" value="0"> WWW <input type="radio" name="source" value="1">
<input type="image" src="images/buttons/find.gif" name="submit" onclick="document.getElementById(\'navbar_search\').submit;" tabindex="100"/>
</form>'
;
}
Reply With Quote
  #12  
Old 02-26-2012, 07:00 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I get

Parse error: syntax error, unexpected $end in /home/midwife/public_html/googlesearch.php on line 1

That when using that?
Reply With Quote
  #13  
Old 02-26-2012, 07:08 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you sure you got it all? Maybe you missed the } on the last line or something.
Reply With Quote
  #14  
Old 02-26-2012, 07:12 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry I'll try it again, im not that hot with this stuff. I appreciate your help honestly I do. This is something I have wanted for ages!

So the above code is meant to go where? replace my googlesearch.php? if so then what goes here -
Code:
echo '<form action="test.php">
?
Reply With Quote
  #15  
Old 02-26-2012, 07:17 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I'm sorry, I wasn't very clear. That's just a test file, it shouldn't replace anything you have. Put it in a file called test.php, copy it to your forum directory, then go to it in your browser. When you press 'submit query' it should go to the forum search page or just print out "search google", depending on which radio button is selected. It's just supposed to show that the radio buttons and the redirect work.
Reply With Quote
  #16  
Old 02-26-2012, 07:24 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And so it does lol.

Sorry for being a total dim ass.

Why wont it work actually on the site then?

I did have a play with this before several times and I just couldnt figure it out
Reply With Quote
  #17  
Old 02-26-2012, 07:29 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So you put this in your googlesearch.php just under the global.php require line?:

Code:
if ($_REQUEST['source'] == 0)  
{  
    $vbulletin->url = 'search.php?do=process&query=' . urlencode($_REQUEST['q']);  
    print_standard_redirect('', false);  
}

If that's true, then temporarily change it to this:

Code:
if (1 || $_REQUEST['source'] == 0)  
{  
    $vbulletin->url = 'search.php?do=process&query=' . urlencode($_REQUEST['q']);  
    print_standard_redirect('', false);  
}

that should make it always go to your site search page.
Reply With Quote
  #18  
Old 02-26-2012, 07:45 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just gives me a blank page again on both radio buttons with this as the url -

Code:
http://www.midwiferyonline.co.uk/googlesearch.php?cx=partner-pub-XXXXXXXXXXXXXXXXXXXX&cof=FORID%3A10&ie=UTF-8&q=help&source=0&submit.x=12&submit.y=17&siteurl=www.midwiferyonline.co.uk%2Fforum.php&ref=www.midwiferyonline.co.uk%2Fsearch.php%3Fsearchid%3D115193
Heres the googlesearch.php

Code:
<?php



// ####################### SET PHP ENVIRONMENT ###########################

error_reporting(E_ALL & ~E_NOTICE);



// #################### DEFINE IMPORTANT CONSTANTS #######################



define('THIS_SCRIPT', 'Googlesearch');

define('CSRF_PROTECTION', true);  

// change this depending on your filename



// ################### PRE-CACHE TEMPLATES AND DATA ######################

// get special phrase groups

$phrasegroups = array();



// get special data templates from the datastore

$specialtemplates = array();



// pre-cache templates used by all actions

$globaltemplates = array('googlesearch',

);



// pre-cache templates used by specific actions

$actiontemplates = array();



// ######################### REQUIRE BACK-END ############################

// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line

// chdir ('/path/to/your/forums');

require_once('./global.php');
if (1 || $_REQUEST['source'] == 0)  
{  
    $vbulletin->url = 'search.php?do=process&query=' . urlencode($_REQUEST['q']);  
    print_standard_redirect('', false);  
}
// #######################################################################

// ######################## START MAIN SCRIPT ############################

// #######################################################################



$navbits = construct_navbits(array('' => 'Google Search'));

$navbar = render_navbar_template($navbits);



// ###### YOUR CUSTOM CODE GOES HERE #####

$pagetitle = 'Google Search';



// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######



$templater = vB_Template::create('googlesearch');

$templater->register_page_templates();

$templater->register('navbar', $navbar);

$templater->register('pagetitle', $pagetitle);

print_output($templater->render());



?>
Reply With Quote
  #19  
Old 02-26-2012, 07:52 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I'm puzzled - it looks OK to me. Try commenting out the print_standard_redirect line (put // in front of it)
Reply With Quote
  #20  
Old 02-26-2012, 08:01 PM
deverill2010 deverill2010 is offline
 
Join Date: Jan 2011
Posts: 412
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah!

Now my search is still giving me the blank page with the funny URL, even though I have removed the edits?

My googlesearch.php is back to how it was and I have removed the bit from the template too..?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:14 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.04284 seconds
  • Memory Usage 2,283KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete