Contentteller

Contentteller Support Forums
Home Forums > Contentteller > Version 1.x >

insert a php script

Discussion in 'Version 1.x' started by capslock, Jun 16, 2005.

  1. capslock Guest

    insert a php script

    I need to insert the latest pics from my gallery in right col of ST.
    Just like this: http://gallery.moddingplanet.it/crandom.php
    Is there a way to do this?
    Thanks a lot
    capslock, Jun 16, 2005
    #1
  2. Philipp Guest

    insert a php script

    Can you post the source code of this script? It should be fairly easy to adapt this.
    Philipp, Jun 16, 2005
    #2
  3. capslock Guest

    insert a php script

    <?php

    //***Enter Path information here***
    //***absolute path to main coppermine directory***

    $copperminepath = 'http://gallery.moddingplanet.it'; //***YOU MUST CHANGE THIS***

    //This connects to the mysql DB
    //***change username and password below***

    $MZrandompic = @mysql_connect('localhost', 'uname', 'password'); //***YOU MUST CHANGE THIS***

    if (!$MZrandompic) {
    echo( '<p>Unable to connect to the ' .
    'database server at this time.</p>' );
    exit();
    }

    //select photo DB
    //***You must change this to match your coppermine database name
    //@mysql_select_db('forum')//
    if (! @mysql_select_db('dbname') ) {
    die( '<p>Unable to locate the picture ' .
    'database at this time.</p>' );
    }

    //This gets a random picture record from the database and
    //the picture's location and displays it
    //change this to match your coppermine table prefix
    //change the limit 0,5 is good for the center block and default thumbnail size//
    $MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,6");
    //$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY ctime DESC LIMIT 0,6");
    if (!$MZresult) {
    die('<p>Error performing query: ' . mysql_error() .
    '</p>');
    }

    while ( $MZrow = mysql_fetch_array($MZresult) ) {

    // $albumid = $MZrow['aid']; //This gets the picture's associated album name
    $pos = $MZrow['pid']; //This finds the picture's coppermine location

    // echo('<P ALIGN=center>');

    echo('<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid .
    '&pos=-' . $pos . '">'); //make thumbnail clickable
    // you cna adjust the thumbnail sizes by changing the with and height//
    //the default is set to border=0 width=60 height=50 //
    //based on the center block size//
    echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure
    echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
    '" alt=' . $MZrow['filename'] . ' '. 'border=0 width=100 height=80>' . '</a> &nbsp;&nbsp;&nbsp;'); //outputs path from /userspics
    echo('<br/>'); //append base dir structure

    }

    //This displays the picture's album name and
    //links it to the coppermine album
    //change this to match your coppermine table prefix
    $MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");
    if (!$MZalbumresult) {
    die('<p>Error performing query: ' . mysql_error() .
    '</p>');
    }

    while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {
    echo('<FONT SIZE=1>');
    echo('<P ALIGN=center>');

    echo('<a href="' . $copperminepath .
    '/thumbnails.php?album=' . $albumid . '">' .
    $MZalbumname['title'] . '</a>' . '</p>');
    }
    // change line below to match your galley database name//
    if (! @mysql_select_db('gallery_moddingplanet_it') ) {
    die( '<p>Unable to reload the main website ' .
    'database at this time.</p>' );
    }

    ?>
    capslock, Jun 16, 2005
    #3
  4. Philipp Guest

    insert a php script

    Ok, here an updated script that should work with Storyteller:

    Code:
    <?php 
    
    //***Enter Path information here*** 
    //***absolute path to main coppermine directory*** 
    
    $copperminepath = 'http://gallery.moddingplanet.it'; //***YOU MUST CHANGE THIS*** 
    
    //This connects to the mysql DB 
    //***change username and password below*** 
    
    $MZrandompic = @mysql_connect('localhost', 'uname', 'password'); //***YOU MUST CHANGE THIS*** 
    
    if (!$MZrandompic) { 
    echo( '<p>Unable to connect to the ' . 
    'database server at this time.</p>' ); 
    exit(); 
    } 
    
    //select photo DB 
    //***You must change this to match your coppermine database name 
    //@mysql_select_db('forum')// 
    if (! @mysql_select_db('dbname') ) { 
    die( '<p>Unable to locate the picture ' . 
    'database at this time.</p>' ); 
    } 
    
    //This gets a random picture record from the database and 
    //the picture's location and displays it 
    //change this to match your coppermine table prefix 
    //change the limit 0,5 is good for the center block and default thumbnail size// 
    $MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,6"); 
    //$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY ctime DESC LIMIT 0,6"); 
    if (!$MZresult) { 
    die('<p>Error performing query: ' . mysql_error() . 
    '</p>'); 
    } 
    
    while ( $MZrow = mysql_fetch_array($MZresult) ) { 
    
    // $albumid = $MZrow['aid']; //This gets the picture's associated album name 
    $pos = $MZrow['pid']; //This finds the picture's coppermine location 
    
    // echo('<P ALIGN=center>'); 
    
    $gallery .= '<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid . 
    '&pos=-' . $pos . '">'; //make thumbnail clickable 
    // you cna adjust the thumbnail sizes by changing the with and height// 
    //the default is set to border=0 width=60 height=50 // 
    //based on the center block size// 
    $gallery .= '<IMG SRC="' . $copperminepath . '/albums/'; //append base dir structure 
    $gallery .= $MZrow['filepath'].thumb_.$MZrow['filename'] . 
    '" alt=' . $MZrow['filename'] . ' '. 'border=0 width=100 height=80>' . '</a>    '; //outputs path from /userspics 
    $gallery .= '<br/>'; //append base dir structure 
    
    } 
    
    //This displays the picture's album name and 
    //links it to the coppermine album 
    //change this to match your coppermine table prefix 
    $MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'"); 
    if (!$MZalbumresult) { 
    die('<p>Error performing query: ' . mysql_error() . 
    '</p>'); 
    } 
    
    while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) { 
    $gallery .= '<FONT SIZE=1>'; 
    $gallery .= '<P ALIGN=center>'; 
    
    $gallery .= '<a href="' . $copperminepath . 
    '/thumbnails.php?album=' . $albumid . '">' . 
    $MZalbumname['title'] . '</a>' . '</p>'; 
    } 
    // change line below to match your galley database name// 
    if (! @mysql_select_db('gallery_moddingplanet_it') ) { 
    die( '<p>Unable to reload the main website ' . 
    'database at this time.</p>' ); 
    } 
    
    ?>
    To use this script, open site_header and add after:

    Code:
    <?php
    global $insert;
    the following:

    Code:
    include("crandom.php");
    Then add in the HTML part of this template $gallery where you like to show your images
    Philipp, Jun 17, 2005
    #4
  5. capslock Guest

    insert a php script

    it gives me this error:

    Error: 1146 Table 'gallery_moddingplanet_it.esselbach_st_online' doesn't exist
    capslock, Jun 18, 2005
    #5
  6. Philipp Guest

    insert a php script

    Add after:

    Code:
    include("crandom.php");
    the following line:

    Code:
    dbconnect();
    Philipp, Jun 19, 2005
    #6
  7. capslock Guest

    insert a php script

    sorry, doesn't work!
    no error now, but nothing showed.
    capslock, Jun 20, 2005
    #7
  8. Philipp Guest

    insert a php script

    Did you add in the HTML part:

    Code:
    $gallery
    Philipp, Jun 20, 2005
    #8
  9. capslock Guest

    insert a php script

    yes i did, but nothink is shown
    capslock, Jun 21, 2005
    #9
  10. Philipp Guest

    insert a php script

    I guess it's time to debug.

    Open the modified crandom script and add before:

    Code:
    ?>
    the following:

    Code:
    echo $gallery;
    Now try to run the script from your browser. Does it work?
    Philipp, Jun 21, 2005
    #10
  11. capslock Guest

    insert a php script

    yes, it works stand alone.
    capslock, Jun 22, 2005
    #11
  12. Philipp Guest

    insert a php script

    In which directory did you copy the modified crandom.php script? In the Storyteller main directory?
    Philipp, Jun 22, 2005
    #12
  13. capslock Guest

    insert a php script

    yes
    capslock, Jun 22, 2005
    #13
  14. Philipp Guest

    insert a php script

    Another idea. Open site_header and add after:

    Code:
    <?php 
    global $insert;
    the entire modified crandom.php script incl. dbconnect();:

    Code:
    //***Enter Path information here*** 
    //***absolute path to main coppermine directory*** 
    
    $copperminepath = 'http://gallery.moddingplanet.it'; //***YOU MUST CHANGE THIS*** 
    
    //This connects to the mysql DB 
    //***change username and password below*** 
    
    $MZrandompic = @mysql_connect('localhost', 'uname', 'password'); //***YOU MUST CHANGE THIS*** 
    
    if (!$MZrandompic) { 
    echo( '<p>Unable to connect to the ' . 
    'database server at this time.</p>' ); 
    exit(); 
    } 
    
    //select photo DB 
    //***You must change this to match your coppermine database name 
    //@mysql_select_db('forum')// 
    if (! @mysql_select_db('dbname') ) { 
    die( '<p>Unable to locate the picture ' . 
    'database at this time.</p>' ); 
    } 
    
    //This gets a random picture record from the database and 
    //the picture's location and displays it 
    //change this to match your coppermine table prefix 
    //change the limit 0,5 is good for the center block and default thumbnail size// 
    $MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,6"); 
    //$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY ctime DESC LIMIT 0,6"); 
    if (!$MZresult) { 
    die('<p>Error performing query: ' . mysql_error() . 
    '</p>'); 
    } 
    
    while ( $MZrow = mysql_fetch_array($MZresult) ) { 
    
    // $albumid = $MZrow['aid']; //This gets the picture's associated album name 
    $pos = $MZrow['pid']; //This finds the picture's coppermine location 
    
    // echo('<P ALIGN=center>'); 
    
    $gallery .= '<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid . 
    '&pos=-' . $pos . '">'; //make thumbnail clickable 
    // you cna adjust the thumbnail sizes by changing the with and height// 
    //the default is set to border=0 width=60 height=50 // 
    //based on the center block size// 
    $gallery .= '<IMG SRC="' . $copperminepath . '/albums/'; //append base dir structure 
    $gallery .= $MZrow['filepath'].thumb_.$MZrow['filename'] . 
    '" alt=' . $MZrow['filename'] . ' '. 'border=0 width=100 height=80>' . '</a>    '; //outputs path from /userspics 
    $gallery .= '<br />'; //append base dir structure 
    
    } 
    
    //This displays the picture's album name and 
    //links it to the coppermine album 
    //change this to match your coppermine table prefix 
    $MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'"); 
    if (!$MZalbumresult) { 
    die('<p>Error performing query: ' . mysql_error() . 
    '</p>'); 
    } 
    
    while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) { 
    $gallery .= '<FONT SIZE=1>'; 
    $gallery .= '<P ALIGN=center>'; 
    
    $gallery .= '<a href="' . $copperminepath . 
    '/thumbnails.php?album=' . $albumid . '">' . 
    $MZalbumname['title'] . '</a>' . '</p>'; 
    } 
    // change line below to match your galley database name// 
    if (! @mysql_select_db('gallery_moddingplanet_it') ) { 
    die( '<p>Unable to reload the main website ' . 
    'database at this time.</p>' ); 
    } 
    
    dbconnect();
    and in the HTML part:

    Code:
    $gallery
    Does this work?
    Philipp, Jun 22, 2005
    #14
  15. capslock Guest

    insert a php script

    no, nothing shown :(
    capslock, Jun 23, 2005
    #15
  16. Philipp Guest

    insert a php script

    Please post your modified site_header template
    Philipp, Jun 23, 2005
    #16
Tweet
Facebook:
Forgot your password?
Contentteller Support Forums
Home Forums > Contentteller > Version 1.x >
  • Home
  • Forums

    Forums

    Quick Links
    • Search Forums
    • What's New?
  • Members

    Members

    Quick Links
    • Registered Members
    • Current Visitors
    • Recent Activity
  • Help

    Help

    Quick Links
    • Smilies
    • BB Codes
    • Trophies

Separate names with a comma.

Advanced search...
    Forum software by XenForo™ ©2011 XenForo Ltd.