Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.6
Author Message
viper155
Regular
Regular



Joined: Feb 18, 2006
Posts: 99

PostPosted: Tue Jan 09, 2007 8:48 pm Reply with quote

Ive been trying to figure out how to get dynamic titles to show on my php nuke video module.

I dont have a good understand on how to go about connecting to a database and then getting the name of the video to display at the top.

Here is my dynamic code im using that doesnt work (prob way off)

Code:
// TT Video

if($name=="Video"){
global $op,$id;
$newpagetitle = "TysonTalk - TT Video";
    if($op=="view") {
        $sql = "SELECT title FROM ".$prefix."_vidmod_videos WHERE id='$id'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $meow = $row[name];
        $newpagetitle = "TysonTalk - TT Video - $meow";
    }
}


A link to the video looks like this /modules.php?name=Video&op=view&video_id=1

Im trying to get the name of the video from the name field


Last edited by viper155 on Wed Jan 10, 2007 4:45 pm; edited 1 time in total 
View user's profile Send private message Visit poster's website
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6441

PostPosted: Tue Jan 09, 2007 10:14 pm Reply with quote

Since there is no title field in the table structure, the SELECT statement will return nothing.

You might try SELECT name (or SELECT *) instead of SELECT title.

_________________
I search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
viper155







PostPosted: Tue Jan 09, 2007 11:04 pm Reply with quote

No go. Sad

This gets frustrating.
 
kguske







PostPosted: Wed Jan 10, 2007 5:45 am Reply with quote

Kind of like trying to troubleshoot without knowing what the error messages or results are... What is happening?
 
technocrat
Life Cycles Becoming CPU Cycles



Joined: Jul 07, 2005
Posts: 511

PostPosted: Wed Jan 10, 2007 10:32 am Reply with quote

You want this:

Code:
if($name=="Video"){

global $op,$video_id;
$newpagetitle = "TysonTalk - TT Video";
    if($op=="view" && is_int($video_id)) {
        $sql = "SELECT title FROM ".$prefix."_vidmod_videos WHERE id='$video_id'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $meow = $row['name'];
        $newpagetitle = "TysonTalk - TT Video - $meow";
    }
}


Though just as an FYI the standard dynamic titles file is embarrassingly insecure.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! / Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message
kguske







PostPosted: Wed Jan 10, 2007 12:19 pm Reply with quote

The image of the table structure is no longer in the original post, but again, the title field isn't in the _vidmod_videos table, so SELECT title won't work.

I haven't looked at the dynamic titles recently, but by insecure do you mean that in this case, for instance, the $video_id variable should be sanitized before using it in a select statement with something like
Code:
$video_id = intval($video_id)
 
technocrat







PostPosted: Wed Jan 10, 2007 12:25 pm Reply with quote

Or at least type checking. Turn off sentinel and try an admin hash union with news sid and watch what happens. Wink

Also to speed it up a little bit you should probably use if/else instead of just if because you are not going to use more than one title type per page. I have it rewritten for Evo and I can give it to you if you wish.
 
kguske







PostPosted: Wed Jan 10, 2007 1:25 pm Reply with quote

That would be great. I'd like to integrate it into nukeSEO, though I am thinking of an object-based approach for that, similar to the one it uses for the sitemap.
 
technocrat







PostPosted: Wed Jan 10, 2007 1:47 pm Reply with quote

Here ya go. Like I said this is for evo, but I am sure you can figure it out.
Code:
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME'])) {

    exit('Access Denied');
}

// Item Delimiter
$item_delim = "»";
$newpagetitle = '';

global $name, $admin_file, $prefix, $db, $user_prefix, $cookie, $slogan, $pagetitle, $sitename;

// Forums
if ($name == 'Forums') {
    global $p, $t, $forum, $f;
    $newpagetitle = "$item_delim $name";
    if (isset($p) && is_numeric($p) && is_int($p)) {
        $p = (int)$p;
        list($title, $post) = $db->sql_ufetchrow("SELECT `post_subject`, `post_id` FROM `".$prefix."_bbposts_text` WHERE `post_id`='$p'", SQL_NUM);
        $newpagetitle = "$name $item_delim Post $post $item_delim $title";
    } else if (isset($t) && is_numeric($t) && is_int($t)) {
        list($title, $forum) = $db->sql_ufetchrow("SELECT `topic_title`, `forum_id` FROM `".$prefix."_bbtopics` WHERE `topic_id`='$t'", SQL_NUM);
        list($forum) = $db->sql_ufetchrow("SELECT `forum_name` FROM `".$prefix."_bbforums` WHERE `forum_id`='$forum'", SQL_NUM);
        $newpagetitle = "$item_delim $name $item_delim $forum $item_delim $title";
    }
    else if (isset($f) && is_numeric($f) && is_int($f)) {
        list($forum) = $db->sql_ufetchrow("SELECT `forum_name` FROM `".$prefix."_bbforums` WHERE `forum_id`='$f'", SQL_NUM);
        $newpagetitle = "$item_delim $name $item_delim $forum";
    }
} else
// News
if ($name == 'News') {
    global $file, $sid, $new_topic;
    $newpagetitle= "$item_delim $name";
    if (isset($new_topic) && is_numeric($new_topic) && is_int($new_topic)) {
        list($top) = $db->sql_ufetchrow("SELECT `topictext` FROM `".$prefix."_topics` WHERE `topicid`='$new_topic'", SQL_NUM);
        $newpagetitle= "$item_delim $top";
    } else if ($file == 'article' && isset($sid) && is_numeric($sid) && is_int($sid)){
        list($art, $top) = $db->sql_ufetchrow("SELECT `title`, `topic` FROM `".$prefix."_stories` WHERE `sid`='$sid'", SQL_NUM);
        if ($top) {
            list($top) = $db->sql_ufetchrow("SELECT `topictext` FROM `".$prefix."_topics` WHERE `topicid`='$top'", SQL_NUM);
            $newpagetitle= "$item_delim $top $item_delim $art";
        } else {
            $newpagetitle= "$item_delim $art";
        }
    }
} else
// Topics
if ($name == 'Topics') {
      $newpagetitle = $item_delim.' '._ACTIVETOPICS;
} else
// Web Links
if ($name == 'Web_Links') {
    global $l_op, $cid, $lid, $module_title;
    $name = $module_title;
    $newpagetitle = "$item_delim $name";
    if($l_op == 'viewlink' && is_numeric($cid) && is_int($cid)) {
        list($cat, $parent) = $db->sql_ufetchrow("SELECT `title`, `parentid` FROM `".$prefix."_links_categories` WHERE `cid`='$cid'", SQL_NUM);
        if ($parent == 0) {
            $newpagetitle = "$item_delim $name $item_delim $cat";
        } else {
            list($parent) = $db->sql_ufetchrow("SELECT `title` FROM `".$prefix."_links_categories` WHERE `cid`='$parent'", SQL_NUM);
            $newpagetitle = "$item_delim $name $item_delim $parent $item_delim $cat";
        }
    }
} else
// Downloads
if ($name == 'Downloads') {
    global $l_op, $cid, $lid, $module_title;
    $name = $module_title;
    $newpagetitle = "$item_delim $name";
    if(isset($cid) && is_numeric($cid) && is_int($cid)) {
        list($cat, $parent) = $db->sql_ufetchrow("SELECT `title`, `parentid` FROM `".$prefix."_downloads_categories` WHERE `cid`='$cid'", SQL_NUM);
        if ($parent == 0) {
            $newpagetitle = "$item_delim $name $item_delim $cat";
        } else {
            list($parent) = $db->sql_ufetchrow("SELECT `title` FROM `".$prefix."_downloads_categories` WHERE `cid`='$parent'", SQL_NUM);
            $newpagetitle = "$item_delim $name $item_delim $parent $item_delim $cat";
        }
    }
} else
// Content
if ($name == 'Content') {
    global $pa, $cid, $pid;
    $newpagetitle = "$item_delim $name";
    if ($pa == 'list_pages_categories' && is_numeric($cid) && is_int($cid)) {
        list($cat) = $db->sql_ufetchrow("SELECT `title` FROM `".$prefix."_pages_categories` WHERE `cid`='$cid'", SQL_NUM);
        $newpagetitle = "$item_delim $name $item_delim $cat";
    } else if ($pa == 'showpage' && is_numeric($pid) && is_int($pid)) {
        list($page, $cid) = $db->sql_ufetchrow("SELECT `title`, `cid` FROM `".$prefix."_pages` WHERE `pid`='$pid'", SQL_NUM);
        list($cat) = $db->sql_ufetchrow("SELECT `title` FROM `".$prefix."_pages_categories` WHERE `cid`='$cid'", SQL_NUM);
        $newpagetitle = "$item_delim $name $item_delim $cat $item_delim $page";
    }
} else
// Reviews
if ($name == 'Reviews') {
    global $rop, $id;
    $newpagetitle = "$item_delim $name";
    if ($rop == "showcontent" && is_numeric($id) && is_int($id)) {
        list($rev) = $db->sql_ufetchrow("SELECT `title` FROM `".$prefix."_reviews` WHERE `id`='$id'", SQL_NUM);
        $newpagetitle = "$item_delim $name $item_delim $rev";
    }
} else
// Stories Archive
if ($name == 'Stories_Archive') {
    global $sa, $year, $month_l, $module_title;
    $name = $module_title;
    $newpagetitle = "$item_delim $name";
    if($sa == 'show_month') {
        $newpagetitle = "$item_delim $name $item_delim $month_l, $year";
    }
} else
// Profile
if ($name == 'Profile') {
    global $mode, $u, $user_prefix, $userinfo;
    $newpagetitle = "$item_delim $name";
    if ($mode == 'viewprofile'  && is_numeric($u) && is_int($u)) {
        list($username) = $db->sql_ufetchrow('SELECT `username` FROM `'.$user_prefix.'_users` WHERE `user_id`='.$u);
        $sec = 'Viewing '.$username.'\'s Profile';
        $newpagetitle = "$item_delim $name $item_delim $sec";
    } else if ($mode == 'editprofile') {
        $sec = 'Editing '.$userinfo['user_name'].'\'s Profile';
        $newpagetitle = "$item_delim $name $item_delim $sec";
    }
}

// Catch all for anything we don't have custom coding for
if (empty($newpagetitle)) {
    global $pagetitle, $module_title;
    if(isset($pagetitle)) {
        $newpagetitle = $pagetitle;
    } else {
        $newpagetitle = "$item_delim $module_title";
    }
}

// Admin Pages
if (defined('ADMIN_FILE')) {
    $newpagetitle = "$item_delim Administration";
}
// If we're on the main page let's use our site slogan
if (defined('HOME_FILE')) {
    $newpagetitle = "$item_delim $slogan";
}

// We're Done! Place the Title on the page
echo "<title>$sitename $newpagetitle</title>\n";
 
kguske







PostPosted: Wed Jan 10, 2007 1:59 pm Reply with quote

Thanks!
 
technocrat







PostPosted: Wed Jan 10, 2007 2:19 pm Reply with quote

NP
 
viper155







PostPosted: Wed Jan 10, 2007 4:32 pm Reply with quote

I got it working by removing the is_int part of your code and changing title to name.

Code:
// TT Video

if($name=="Video"){
global $op,$video_id;
$newpagetitle = "TysonTalk - TT Video";
    if($op=="view" && ($video_id)) {
        $sql = "SELECT name FROM ".$prefix."_vidmod_videos WHERE id='$video_id'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $meow = $row['name'];
        $newpagetitle = "TysonTalk - TT Video - $meow";
    }
}


Thank you so much to all of you that helped Smile
 
kguske







PostPosted: Wed Jan 10, 2007 8:04 pm Reply with quote

Not sure why is_int didn't work - that's a security check.
 
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Wed Jan 10, 2007 9:56 pm Reply with quote

is_int() only checks if the variable itself is an integer type. The proper function to use is is_numeric()

http://us3.php.net/is_int

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
technocrat







PostPosted: Thu Jan 11, 2007 10:04 am Reply with quote

is_int should be working as the id field in the DB is an int and is_int will parse strings show I dont know why it would fail
 
evaders99







PostPosted: Thu Jan 11, 2007 10:40 am Reply with quote

According to PHP.net,
Quote:

Note: To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().


That would seem to indicate that is_int does not do strings correctly.
 
technocrat







PostPosted: Thu Jan 11, 2007 10:54 am Reply with quote

Yep your right I just tried it and it failed. That sucks, I am going to have to change a few things.
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.6

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©