[問題]在論壇首頁顯示CPG的隨機圖片

CPG Running Discuss
關於 CPG 架設使用操作討論,非本程式相關問題一律砍文!

版主: 版主管理群

anson_wongy
星球普通子民
星球普通子民
文章: 26
註冊時間: 2004-04-25 09:46
來自: 我阿媽個肚!

[問題]在論壇首頁顯示CPG的隨機圖片

文章 anson_wongy »

請問各位大大有沒有一些能在在論壇首頁上顯示CPG的隨機圖片的MOD呢?
:oops:
annion
星球普通子民
星球普通子民
文章: 5
註冊時間: 2004-04-06 15:42

文章 annion »

askaitski
星球公民
星球公民
文章: 38
註冊時間: 2004-12-14 04:01

文章 askaitski »

請問   這個有人裝成功嗎

可否教一下小弟

感恩
jafeng
星球普通子民
星球普通子民
文章: 2
註冊時間: 2004-10-18 15:18

文章 jafeng »

askaitski 寫:請問   這個有人裝成功嗎

可否教一下小弟

感恩
小弟我的網頁有試過,你可以先去看看,是不是像這樣的效果....

http://220.132.146.80
頭像
godbless
竹貓忠實會員
竹貓忠實會員
文章: 647
註冊時間: 2002-05-17 06:02
來自: 台北市南京東路4段
聯繫:

文章 godbless »

掛了~

有誰知道他的標題嗎?
外掛問題區發問格式就在這裡,請務必一定照著格式來~!
你不照著規則來,就算是也搞不清楚你的問題在哪裡!
新手問問題不是罪惡
罪惡的是自己沒有先做好本分和功課,說話的口氣也不好,再加上態度有好像我們這群人欠你多少似的~~!!
竹貓星球發問規則:
http://phpbb-tw.net/phpbb/viewtopic.php?t=16149
發問比率最高的句子翻譯:
Please ensure both the install/ and contrib/ directories are deleted
請確認install和contrib資料夾已被刪除(奇怪,翻一下英漢字典有這麼困難嗎)
annion
星球普通子民
星球普通子民
文章: 5
註冊時間: 2004-04-06 15:42

文章 annion »

andy8090
星球公民
星球公民
文章: 85
註冊時間: 2005-05-10 15:51

文章 andy8090 »

這是個很好的課題,在竹貓為何討論如此的少
網路搜尋也找不到像樣的文章
可有高手挺身而出,幫幫我們 :roll:
andy8090
星球公民
星球公民
文章: 85
註冊時間: 2005-05-10 15:51

文章 andy8090 »

為何都找不到cpg,如何在首頁顯示ㄉ掛呢??
bochin1010
星球普通子民
星球普通子民
文章: 4
註冊時間: 2002-10-28 19:50

文章 bochin1010 »

http://coppermine-gallery.net/forum/ind ... ic=9829.20

看了這篇 也做了gallery_block.php
可是gallery_block.php 就是不會顯示
問題出在哪?
我的gallery_block.php 都是空白一片
因為空白所以我也沒整合進 overall_header.tpl

我的相簿http://xxx..../gallery/
我的論壇http://xxx.../phpbb2/

我把gallery_block.php 放在跟gallery同目錄下

語法裡面說有幾個地方要改\r
我的改法如下:
include ('include/config.inc.php');

$copperminepath = '/gallery'; //***YOU MUST CHANGE THIS***

這一段說要改\r
$MZrandompic = @mysql_connect("$host", "$username", "$userpass"); //***YOU MUST CHANGE THIS***

我把$去掉 改成我資料庫帳號跟密碼\r

外國成功的樣子:

http://www.amadistrictii.org/amad2/
http://www.amadistrictii.org/amad2/gall ... _block.php

搞了好幾個小時 就是顯示不出來 有人知道怎麼用???
問題出在哪..
頭像
arrestgirl
星球普通子民
星球普通子民
文章: 5
註冊時間: 2005-08-13 22:15

[轉貼] [教學] cpg在phpbb上顯示隨機圖片方法

文章 arrestgirl »

取自:cpg官方網站 文章 及cpg中文教學網站綠光森林文章 作者:itski

1:安裝eXtreme styles 此外掛

2:將下面這段code加入你的index_body.tpl中\r

代碼: 選擇全部

<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> 
<tr> 
<td class="catHead" height="25"><span class="genmed"><b>隨機圖片</b></span></td> 
</tr> 
<tr> 
<td class="row1" align="center"> 
<?php 
//<?php 

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

$copperminepath = './gallery'; //***YOU MUST CHANGE THIS*** 

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

$MZrandompic = @mysql_connect('localhost', 'root', '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*** 

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 

$MZresult = @mysql_query("SELECT * FROM cpg133_pictures ORDER BY RAND() LIMIT 0,4"); 
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 
$filepath = $MZrow['filepath']; 
$filename = $MZrow['filename']; 

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

echo('<a href="' . $copperminepath . '/displayimage.php?album=' . $albumid . 
'&pos=-' . $pos . '">'); //make thumbnail clickable 

echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure 
echo( $filepath .normal_. $filename . 
'" alt=' . $MZrow['title'] . ' '. 'border=0 height=150></a>&nbsp; &nbsp;'); //outputs path from /userspics
} 

//This displays the picture's album name and 
//links it to the coppermine album 

$MZalbumresult = @mysql_query("SELECT * FROM cpg133_albums WHERE aid = '$albumid'"); 
if (!$MZalbumresult) { 
die('<p>Error performing query: ' . mysql_error() . 
'</p>'); 
} 

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

echo('<a href="' . $copperminepath . 
'/thumbnails.php?album=' . $albumid . '">' . 
$MZalbumname['title'] . '</a>' . '</p>'); 
} 

if (! @mysql_select_db('dbname) ) { 
die( '<p>Unable to reload the main website ' . 
'database at this time.</p>' ); 
} 

//?> 
</td> 
</tr> 
</table>
3:請修改下面紅色標記的地方\r

  a.找尋$copperminepath = './gallery'; //***YOU MUST CHANGE THIS***
   gallery:請將gallery修改為您的cpg安裝的資料夾名,在phpbb和cpg結合的安裝教學幾乎都是以gallery為資料夾名

  b.找尋$MZrandompic = @mysql_connect('localhost', 'root', 'password'); //***YOU MUST CHANGE THIS***
   localhost:一般localhost即可\r
   root:輸入您的資料庫使用者帳號
   password:輸入您的資料庫密碼\r

  c.找尋if (! @mysql_select_db('dbname') ) { die( '<p>Unable to locate the picture ' . 'database at this time.</p>' ); }
   dbname:請輸入完整資料庫名稱,有2處要修改\r

  d.找尋$MZresult = @mysql_query("SELECT * FROM cpg133_pictures ORDER BY RAND() LIMIT 0,4");
   cpg133:修改為cpg的版本,例如cpg132
   4:修改為一列要呈現幾張圖片,例如要6就改為6

  e.找尋echo( $filepath .normal_. $filename . '" alt=' . $MZrow['title'] . ' '. 'border=0 height=150></a>&nbsp; &nbsp;');
   height=150:修改為圖片顯示尺寸大小

  f.找尋$MZalbumresult = @mysql_query("SELECT * FROM cpg133_albums WHERE aid = '$albumid'");
   cpg133:修改為cpg的版本,例如cpg132

4.這樣就ok了,我測試完全ok

5.補充,如有錯誤修幫忙修正,還有一個問題,我想在圖片下面顯示該圖片名稱,不知如何修改,如果有高手請指教一下...Tks
bochin1010
星球普通子民
星球普通子民
文章: 4
註冊時間: 2002-10-28 19:50

文章 bochin1010 »

我裝了eXtreme styles (覆蓋而已 不知道是不是這樣裝...) 
這原始方法可行
但要是我執行你的 tpl 檔案 然後檢視原始碼\r
就可以知道你的資料庫帳號跟密碼

第二頁有人寫的gallery_block.php 就不會被看到帳號密碼\r
我沒有修改帳號密碼  因為他是$變數\r
資料擷取於config.inc.php設定頁
但我執行卻是一片空白.....還是搞不定
yll
星球公民
星球公民
文章: 149
註冊時間: 2002-09-08 15:26
來自: http://www.yll.url.tw/
聯繫:

文章 yll »

看看我網站上的範例
http://yll.loxa.edu.tw/phpBB2/
是你要的嗎
如果是\r
願意分享我的笨方法... :roll:
bochin1010
星球普通子民
星球普通子民
文章: 4
註冊時間: 2002-10-28 19:50

文章 bochin1010 »

沒錯  我就是要這種感覺 麻煩您了
bochin1010
星球普通子民
星球普通子民
文章: 4
註冊時間: 2002-10-28 19:50

文章 bochin1010 »

我自己想到了
把這些內容 做成一個PHP檔案
然後再用includ 語法 把檔案叫出來
這樣原始碼應該就不會顯示出來了 :-P
yll
星球公民
星球公民
文章: 149
註冊時間: 2002-09-08 15:26
來自: http://www.yll.url.tw/
聯繫:

文章 yll »

我是把程式碼加在page_header.php中\r
然後在index_body.tpl中用自己想要的方式呈現\r
給你參考
回覆文章

回到「Coppermine Photo Gallery」