Thread: Coding problem
View Single Post
  #7  
Old 02-08-2016, 02:02 PM
jagtpf jagtpf is offline
 
Join Date: Mar 2015
Location: Scotland
Posts: 176
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
That happens because you're not escaping the variable correctly.

The following is the right way:
PHP Code:
$template_hook['postbit_userinfo_right_after_posts'] .= 
'<br><dt>Nominate for Members Choice Award </dt> <dd><a href="testingthread.php?threadid=' $threadinfo['title'] . '"> <img src="images/buttons/memchoice.png" style="width: 26px; height: 26px; border: 0px;" alt="Nominate This Poem for Members Choice Award. Thank you."></a></dd>'
Thanks Dave . Always the 'little' things that upset the proverbials !

--------------- Added [DATE]1454947523[/DATE] at [TIME]1454947523[/TIME] ---------------

To get a working work-around I settled on the following .

HTML Code:
					{vb:raw template_hook.postbit_controls}
<vb:if condition="(in_array($thread['forumid'], array(189,105,104,114,115,109,110,111,113,112,207,106,116,108,216,225,226,231,247))) AND ($post[postcount] == '1'))">                                       
<a href="testingthread.php?{vb:raw session.sessionurl}do=&amp;p={vb:raw post.postid}" rel="nofollow" title="Nominate This Poem for Members Choice Award"><img src="images/buttons/memchoice.png" style="width: 26px; height: 26px; border: 0px;" alt="Nominate This Poem for Members Choice Award. Thank you." /> &nbsp; </a>
</vb:if>
Placed in "postbit legacy" template .

--------------- Added [DATE]1454947988[/DATE] at [TIME]1454947988[/TIME] ---------------

The accompanying .php file works as expected except it doesn't always trap the "cannot self-nominate" section - but I'll sort it out .

I've also got the layout to address in the newpost, but otherwise the following is working.

I fully appreciate it's probably very 'raw' with stuff that shouldn't be in there and stuff that ought to be added - If anyone can find any glaring issues - please advise. I've bundled together ideas from numerous places and the end result may not be 'tidy' in the eyes of experience - sadly lacking in myself!

Things to change at a later stage when I've had a breather would be a 'better' call-out on the "Cannot Self-Nominate" and a "Thank-you for Nominating" at the end of the routine ....

warmly Geoff

PHP Code:

error_reporting
(E_ALL & ~E_NOTICE & ~8192);

define('GET_EDIT_TEMPLATES'true);
define('THIS_SCRIPT''testingthread');
define('CSRF_PROTECTION'true);

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

global 
$postid;

$_REQUEST['postid'];

    
$vbulletin->input->clean_array_gpc('p', array(
        
'$Alto_nom'=> TYPE_STR,
        
'$Alto_poet' => TYPE_STR,
        
'$Alto_nomID'=> TYPE_INT,
        
'$Alto_poetID' => TYPE_INT,
        
'$Alto_title' => TYPE_STR,
        
'$Alto_forum' => TYPE_STR,
        
'$Alto_poemid' => TYPE_INT,
    ));
    
    
$Alto_nom $postinfo['username']; //Gives name of poet
    
$Alto_poet $vbulletin->userinfo['username']; //Gives name of nominator
    
$Alto_nomID $postinfo['userid']; //Gives ID of poet
    
$Alto_poetID $vbulletin->userinfo['userid']; //Gives ID of nominator
    
$Alto_title $threadinfo['title']; //Gives title of poem
    
$Alto_forum $foruminfo['title']; // Gives name of Forum
    
$Alto_poemid $postinfo['threadid']; //Gives ID of thread
    
    /*Check own poem isn't being nominated !*/ 
if ($Alto_nomID == $Alto_poetID
    {
    echo 
"Whoops, I'm sorry, you may not nominate your own poem." "<br><br>" "Please press back-button on your browser. Thank you";
    eval(
print_standard_redirect('')); //Return to thread/post
    
}
    
/*Set for output to post*/
    
    /*Set the subject */
    
$Alto_subject "Nomination for Member's Choice Award";
    
/*Set the contents*/
    
$Alto_text "Poet =" .  $Alto_nom .  "Poem Title =" .  $Alto_title "Forum = " $Alto_forum "Poem Link =" "[URL]" "http://localhost/poetsl/showthread.php?" .  $Alto_poemid "[/URL]";
    
/*Post thread to nominated Forum*/

/*Create a new datamanager for posting*/
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');

/*Bits & pieces*/
$forumid '260';                                                                  // ID of Destination Forum (Adjust Accordingly) - Should Equate to "Members' Choice Nominations" (260 on Test)
$userid $Alto_poetID;                                                                 // The name of the nominator
$title $Alto_subject;                                            // Thread subject title
$pagetext $Alto_text;                                       // Content 
$allowsmilie '0';                                                             // No smilies
$visible '1';                                                                 // Post visible

// Parse, retrieve and process the information we need to post
$foruminfo fetch_foruminfo($forumid);
$threadinfo = array();
$user htmlspecialchars_unifetch_userinfo($userid) );

$threaddm->set_info('forum'$foruminfo);
$threaddm->set_info('thread'$threadinfo);
$threaddm->setr('forumid'$forumid);
$threaddm->setr('userid'$userid);
$threaddm->setr('pagetext'$pagetext);
$threaddm->setr('title'$title);
$threaddm->set('allowsmilie'$allowsmilie);
$threaddm->set('visible'$visible);

// Lets see what happens if we save the page
$threaddm->pre_save();
if(
count($threaddm->errors) < 1) {
    
// Basically if the page will save without errors then let do it for real this time
    
$threadid $threaddm->save();
    unset(
$threaddm);
} else {
    
// There was errors in the practice run, so lets display them
    
var_dump ($threaddm->errors);
    
    exit();
}

//$threadid = $threaddm->save();  
eval(print_standard_redirect('')); //Return to thread/post 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01807 seconds
  • Memory Usage 1,857KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete