Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: 1 [2]   Go Down

Author Topic: how to add custom php script - DOESN'T WORK :(  (Read 23818 times)

0 Members and 1 Guest are viewing this topic.

shutiri

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 66
Re: how to add custom php script - DOESN'T WORK :(
« Reply #20 on: May 09, 2004, 09:30:55 am »

ok...  thank you. 
Can I create a new topic with the title "phpadsnew/CPG integration" so if somebody knows or already had this trouble can answer me ?

shutiri.
Logged

sigepjedi

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 111
Re: how to add custom php script - DOESN'T WORK :(
« Reply #21 on: June 06, 2004, 08:58:26 pm »

GauGau


Ive read through many of the posts regarding phpads, and implementing the banner invokation code into coopermine, and as with many of the others Ive ran into the same problems.

Ive followed all the steps throughout this post regardig the modification of theme.php and creating '{BANNER}' => theme_custom_banner() in the $template_vars portion of this file.

Having said that, and reaching the same road blocks, here is a new piece of information to this puzzel:
Running debug upon reaching the roadblock "There was an error while processing a database query."
Ive come across the following:

------------------------
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures  WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0
mySQL error: Table 'adclicks.bw_comments' doesn't exist
------------------------

'BW' is my prefix for Coopermine, and 'adclicks' is my prefix for my phpads database.

If looks as though calling the invocation code of phpads is placing its database name infront of the remaining calls in coopermine. And then the rest just goes to hell.

Thoughts?

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #22 on: June 06, 2004, 10:58:22 pm »

yes: the mySQL connection to your banner software hasn't been established properly. I'm not sure if your banner script will work at all - you simply can't combine some sorts of scripts.

GauGau
Logged

DefenceTalk.com

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 230
    • http://www.defencetalk.com
Re: how to add custom php script - DOESN'T WORK :(
« Reply #23 on: June 07, 2004, 01:51:31 pm »

Interesting. Use anycontent.php to accomplish this. Take a look at our website. The rotating amazon ads at the bottom. ;)
Logged
(http://www.defencetalk.com/pictures/signature_cpg.php)

sigepjedi

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 111
Re: how to add custom php script - DOESN'T WORK :(
« Reply #24 on: June 07, 2004, 05:56:47 pm »

Interesting. Use anycontent.php to accomplish this. Take a look at our website. The rotating amazon ads at the bottom. ;)

We are using that method of calling banners. I dont think you are grasping the issue at hand with PHPADS.

GAUGAU:

Is there a way in which to re-set the coppermine DB names, or DB prefixes. I think if i re-set this variable after I make my call to phpads, then everything would be back to normal in the coopermine world following the PHPADS call.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #25 on: June 07, 2004, 06:54:51 pm »

I don't understand fully - do you mean you want to end the established connection to the db at some point, or do you want to just rename the prefix once?

GauGau
Logged

sigepjedi

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 111
Re: how to add custom php script - DOESN'T WORK :(
« Reply #26 on: June 07, 2004, 08:46:21 pm »

in calling the banner.php code, thus initiating the communication link to PHPADS, it apparently sets the DB prefix or connection VAR to its own known variable.

-----------EXAMPLE---------------
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures  WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0
mySQL error: Table 'adclicks.bw_comments' doesn't exist
-----------EXAMPLE---------------

coopermine fires, DB name/prefix =  "BW_"
PHPADS fires, DB name/prefix is modified to: "adclicks.BW_"

apparently it overwrites this prefix variable used in DB connectivity.

After I make my call to PHPADS, can i re-initiate the coppermine DB prefix back to "BW_"?

So my code for banner.php would look something like:

Quote
<?php
// PHPADS BANNER CODE
   if (@include('C:/PHPADS/phpadsnew.inc.php')) {
        if (!isset($phpAds_context)) $phpAds_context = array();
        $phpAds_raw = view_raw ('', 31, '_blank', '', '0', $phpAds_context);
        $phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
    } 
    // Assign the $phpAds_raw['html'] variable to your template
    echo $phpAds_raw['html'];
   $banner = "<center>$phpAds_raw['html']</center>";
// PHPADS BANNER CODE

//RE-INITIATE THE DB PREFIX HERE

?>

So that once PHPADS was done, and coopermine continues through its processes remaining, it has the correct DB prefix.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: how to add custom php script - DOESN'T WORK :(
« Reply #27 on: June 08, 2004, 08:06:03 am »

I'm not sure what vars are being reset by phpAds, try re-setting the db prefix after the phpAds code like this:
Code: [Select]
$CONFIG['TABLE_PREFIX'] = "yourCopperminePrefix_";
GauGau
Logged

sigepjedi

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 111
Re: how to add custom php script - DOESN'T WORK :(
« Reply #28 on: June 08, 2004, 05:45:43 pm »

Negative Ghost-Rider, same thing.

I added to the last line of my Banner.php file the re-setting of the DB prefix var.

DEBUG INFO

There was an error while processing a database query.
Quote
While executing query "SELECT COUNT(*) from BW_comments, BW_pictures  WHERE approved = 'YES' AND BW_comments.pid = BW_pictures.pid " on 0

mySQL error: Table 'adclicks.bw_comments' doesn't exist


File: C:\The\Path\To\MySite\include\functions.inc.php - Line: 101


Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098
Notice: Undefined index: pid in C:\The\Path\To\MySite\include\functions.inc.php on line 1098

Line 101 of functions.inc.php contains the following (LN 87- LN 103)
Quote
// Error message if a query failed
function db_error($the_error)
{
        global $CONFIG;

        if (!$CONFIG['debug_mode']) {
            cpg_die(CRITICAL_ERROR, 'There was an error while processing a database query', __FILE__, __LINE__);
        } else {

                $the_error .= "\n\nmySQL error: ".mysql_error()."\n";

                $out = "<br />There was an error while processing a database query.<br /><br/>
                    <form name='mysql'><textarea rows=\"8\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form>";

            cpg_die(CRITICAL_ERROR, $out, __FILE__, __LINE__);
        }
}

Line 1098 of functions.inc.php contains the following (LN1091 - LN 1102)
Quote
     if((($mode == "normal") || ($mode == 'fullsize')) && ($CONFIG['thumb_method']=='im')){

               // return the url to the wm script
               return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

       }else{
               // it's a thumb, don't bother wm'ing
               if (is_null($pic_row['pid']) || !isset($CONFIG['url_mode']) || $CONFIG['url_mode']!='hide')
                return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
             return 'get_file.php?pid='.$pic_row['pid'].'&size='.$mode;

       }

and, at the very bottom the SQL Query Debug Info:
Quote
USER:
Array
(
    [ID] => f906caa6dd5e01a219b7fb162eca3287
    [am] => 1
    [liv] => Array
        (
           
  • => 108
  • [1] => 263
                [2] => 78
                [3] => 202
            )

    )

     
    GET :
    Array
    (
    )

     
    POST :
    Array
    (
    )

Thoughts?
Logged

jriba

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 21
Re: how to add custom php script - DOESN'T WORK :(
« Reply #29 on: December 19, 2004, 02:26:33 am »

GauGau:

What's the PRO/CON of making a function in theme.php for the phpAdsNew code (or any other code for that matter) and then inserting the {BANNER} tag into template.html

vs.

insertint the phpAdsNew code directly into template.html ???
Logged

Nibbler

  • Guest
Re: how to add custom php script - DOESN'T WORK :(
« Reply #30 on: December 19, 2004, 02:45:17 am »

Only html can go into the template. PHP goes into the theme.php
Logged

lucasnet

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 37
    • TUNING 4U
Re: how to add custom php script - DOESN'T WORK :(
« Reply #31 on: December 24, 2004, 01:11:04 am »

I have a question. I use this solution but i have 1 problem. When i enetered a this codes script show at the bottom of page. Not where {BLABLA} is but at first, before logo. ??? What i must do ?
Logged
LuCaS ( lucas@tuning4u.info ) GG: 40139
---------------------------------------------------------
http://tuning4u.info - best wallpapers and tuning photos

Nibbler

  • Guest
Re: how to add custom php script - DOESN'T WORK :(
« Reply #32 on: December 24, 2004, 01:28:02 am »

The code you have added probably outputs using echo or similar. It should return all its output as the result of the function in which it resides. If you can't do this easily you can use output buffering to capture the output.
Logged

jriba

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 21
Re: how to add custom php script - DOESN'T WORK :(
« Reply #33 on: January 06, 2005, 05:55:45 am »

I have solved this problem!

Add the phpAdsNew "Local Mode" php invocation code to the "../include/functions.inc.php" file.  Add it "AS IS" how the phpAdsNew code generator gives it to you.  Make sure to click on "Store the banner inside a variable so it can be used in a template" before generating the phpAdsNew code.  And add it to functions.inc.php at the very top, before
Code: [Select]
// Decode the user profile contained in a cookie
function user_get_profile()

Thats it for the functions.inc.php file.

Edit themes.php, find:
Code: [Select]
global $CONFIG, $THEME_DIR;replace it with:
Code: [Select]
global $CONFIG, $THEME_DIR, $phpAds_raw;
and find:
Code: [Select]
'{ADMIN_MENU}' => theme_admin_mode_menu()add after:
Code: [Select]
'{BANNER}' => $phpAds_raw['html']
and make sure to add a comma (" , ") at the end of
Code: [Select]
'{ADMIN_MENU}' => theme_admin_mode_menu() to make it look like this
Code: [Select]
'{ADMIN_MENU}' => theme_admin_mode_menu(),since you are adding to the array.

That's it..

Enjoy!
Logged

lucasnet

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 37
    • TUNING 4U
Re: how to add custom php script - DOESN'T WORK :(
« Reply #34 on: January 06, 2005, 04:32:58 pm »

Thanks  ;)
Logged
LuCaS ( lucas@tuning4u.info ) GG: 40139
---------------------------------------------------------
http://tuning4u.info - best wallpapers and tuning photos

jriba

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 21
Re: how to add custom php script - DOESN'T WORK :(
« Reply #35 on: January 06, 2005, 10:33:09 pm »

I should probably also mention 2 things that might be obvious to some, but not others:

1) Remember to put the {BANNER} where ever you want the banner to appear in template.html

2) Remember to take out the first and last lines of the invocation code: "<$php" and "?>", when you put it in functions.inc.php

That's it!
Logged
Pages: 1 [2]   Go Up
 

Page created in 0.032 seconds with 19 queries.