vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - Photopost Pro Random Image Widget (https://vborg.vbsupport.ru/showthread.php?t=234589)

rosebudtr 03-22-2011 06:22 PM

<a href="http://www.dizilerimizden.com" target="_blank">www.dizilerimizden.com</a> . i added my cms

stl7997 04-03-2011 07:12 PM

Works for me, thanks for this!

http://www.aerovacworld.com (left side of page)

sjm14 07-14-2011 09:57 AM

Great! but I cannot get it to work I've installed it but I'm getting this message

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'database_server' (1) in [path]/packages/vbcms/widget/execphp.php(191) : eval()'d code on line 6

Can you point me in the right direction please, Dummies guide;-)

8thos 07-25-2011 06:52 AM

Interesting.

bpi007 07-25-2011 07:02 AM

Quote:

Originally Posted by sjm14 (Post 2220374)
Great! but I cannot get it to work I've installed it but I'm getting this message

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'database_server' (1) in [path]/packages/vbcms/widget/execphp.php(191) : eval()'d code on line 6

Can you point me in the right direction please, Dummies guide;-)

Have you change something in :

Code:

$host  = 'localhost';
If yes, try like original post.

tommyxv 08-16-2011 03:11 AM

isn't there a way to reference (require once or include) a custom php file that can store the database and password info instead of putting it into the widget itself? Don't want all admins to have that info.

glaive 04-18-2012 02:24 PM

Here's an update to this code using vb db class type stuff I learned from migrating another project from vb 3.8x to v4.x. Now the "dangerous" db connection stuff is not available to any who read the code.

My version comments out two query executions you will need if your photopost db is different than your vb db.

I have also tweaked the query to fix an issue where the storage cat was different than the cat field and not 0 ( meaning catstore was not used.

My code builds on 9 random images in a simple table.

Note that I pull the cat out as cat_real and not just cat anymore.

I give this code freely to the original author and the community. I will try to mind the thread to help people and/or the OP. Thank you ZippySLC for getting my brain rolling on this.

You can see my version working here.

PHP Code:

ob_start();

// If your photo_post is not in the vbulletin db
//$sql_pp_db="USE Replace_with_PhotoPost_DB_name";
//$GLOBALS["vbulletin"]->db->query_read($sql_pp_db);

$sql_rp = <<<SQL
  SELECT
    id,
    if(
      storecat = 0,
      cat,
      if(
        cat != storecat,
        storecat,
        cat
      )
    ) as cat_real,
    bigimage
  FROM
    pp_photos
  ORDER BY rand()
  LIMIT 9
SQL;

$result_rp $GLOBALS["vbulletin"]->db->query_read($sql_rp);

echo 
"<center>";
echo 
"<table>";
$x 0;
while((
$array_rp $GLOBALS["vbulletin"]->db->fetch_array($result_rp)))
{
  if( 
$x == )
  {
    echo 
"<tr>";
  }
  elseif( 
$x == )
  {
    echo 
"</tr><tr>";
  }
  echo 
"<td>";
  echo 
"<a href=\"/gallery/showphoto.php/photo/" $array_rp["id"] . "\">";
  echo 
"<img src=\"/gallery/data/" $array_rp["cat_real"] . "/thumbs/" .  $array_rp["bigimage"] . "\" />";
  echo 
"</a></td>\n";
  
$x++;
}
 echo 
"</tr></table><br /><a href=\"/gallery\">See more photos in the Gallery</a></center>\n";

// If your photo_post is not in the vbulletin db
//$sql_pp_db="USE Replace_with_vbulletin_DB_name";
//$GLOBALS["vbulletin"]->db->query_read($sql_pp_db);

$output .= ob_get_contents();
ob_end_clean(); 


Magnusson2u 05-22-2012 01:52 AM

Quote:

Photopost tables don't have the pp_ prefix, you'll need to alter the code to reflect your prefix.
Hi,

How/where would I place/define this?

PHP Code:

$result+=+mysql_query("SELECT+id,cat,bigimage+FROM+pp_photos+order+by+rand()+LIMIT+1"+)+or+die(mysql_error());+++ 
while(
$row+=+mysql_fetch_array(+$result+))+ 

Do I replace "pp_photos" with the name of my database?

Thanks in advance...

BGObsession 01-25-2014 11:28 PM

Quote:

Originally Posted by glaive (Post 2321297)
Here's an update to this code using vb db class type stuff I learned from migrating another project from vb 3.8x to v4.x. Now the "dangerous" db connection stuff is not available to any who read the code.

My version comments out two query executions you will need if your photopost db is different than your vb db.

I have also tweaked the query to fix an issue where the storage cat was different than the cat field and not 0 ( meaning catstore was not used.

My code builds on 9 random images in a simple table.

Note that I pull the cat out as cat_real and not just cat anymore.

I give this code freely to the original author and the community. I will try to mind the thread to help people and/or the OP. Thank you ZippySLC for getting my brain rolling on this.

You can see my version working here.

PHP Code:

ob_start();

// If your photo_post is not in the vbulletin db
//$sql_pp_db="USE Replace_with_PhotoPost_DB_name";
//$GLOBALS["vbulletin"]->db->query_read($sql_pp_db);

$sql_rp = <<<SQL
  SELECT
    id,
    if(
      storecat = 0,
      cat,
      if(
        cat != storecat,
        storecat,
        cat
      )
    ) as cat_real,
    bigimage
  FROM
    pp_photos
  ORDER BY rand()
  LIMIT 9
SQL;

$result_rp $GLOBALS["vbulletin"]->db->query_read($sql_rp);

echo 
"<center>";
echo 
"<table>";
$x 0;
while((
$array_rp $GLOBALS["vbulletin"]->db->fetch_array($result_rp)))
{
  if( 
$x == )
  {
    echo 
"<tr>";
  }
  elseif( 
$x == )
  {
    echo 
"</tr><tr>";
  }
  echo 
"<td>";
  echo 
"<a href=\"/gallery/showphoto.php/photo/" $array_rp["id"] . "\">";
  echo 
"<img src=\"/gallery/data/" $array_rp["cat_real"] . "/thumbs/" .  $array_rp["bigimage"] . "\" />";
  echo 
"</a></td>\n";
  
$x++;
}
 echo 
"</tr></table><br /><a href=\"/gallery\">See more photos in the Gallery</a></center>\n";

// If your photo_post is not in the vbulletin db
//$sql_pp_db="USE Replace_with_vbulletin_DB_name";
//$GLOBALS["vbulletin"]->db->query_read($sql_pp_db);

$output .= ob_get_contents();
ob_end_clean(); 


This is working great for me. If anyone wants to see it in action, you can see it in my left CMS column at http://www.bgobsession.com/content/

I changed the '9' to '1' as I want just a single random photo showing. Only questions I have are, does the photo change daily or should it be changing with every screen refresh (I expected it to change with every screen refresh but that doesn't seem to be the case). Also - is it possible to make the pulled image a little bigger or define the default width and height (the pulled image is smaller than I'd like for that widget)?


All times are GMT. The time now is 11:01 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.01365 seconds
  • Memory Usage 1,767KB
  • 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
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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