die Änderungen sind für den "Full Album Pack" gedach und nicht für das normale Album von Smartor

Den Link dorthin findest du im ersten Beitrag auf dieser Seite
Markus
Code: Alles auswählen
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// ------------------------------------
// Check the request
// ------------------------------------
if( isset($HTTP_GET_VARS['pic_id']) )
{
$pic_id = intval($HTTP_GET_VARS['pic_id']);
}
else if( isset($HTTP_POST_VARS['pic_id']) )
{
$pic_id = intval($HTTP_POST_VARS['pic_id']);
}
else
{
message_die(GENERAL_MESSAGE, 'No pics specified');
}
//--- Album category Hierarchy : begin
//--- version : 1.1.0
// ------------------------------------
// Get this pic info
// ------------------------------------
$sql = "SELECT pic_filename, pic_thumbnail
FROM ". ALBUM_TABLE ."
WHERE pic_id = '$pic_id'";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not query pic information', '', __LINE__, __FILE__, $sql);
}
$thispic = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$pic_filetype = substr($thispic['pic_filename'], strlen($thispic['pic_filename']) - 4, 4);
$pic_filename = $thispic['pic_filename'];
if( empty($thispic) or !file_exists(ALBUM_UPLOAD_PATH . $pic_filename) )
{
message_die(GENERAL_MESSAGE, $lang['Pic_not_exist']);
}
// ------------------------------------
// Okay, now we can send image to the browser
// ------------------------------------
switch( $pic_filetype )
{
case '.png':
header('Content-type: image/png');
break;
case '.gif':
header('Content-type: image/gif');
break;
case '.jpg':
header('Content-type: image/jpeg');
break;
default:
message_die(GENERAL_MESSAGE, 'The filename data in the DB was corrupted');
}
readfile(ALBUM_UPLOAD_PATH . $thispic['pic_filename']);
exit;
?>
Dazu habe ich den folgenden Codeschnippsel benutzt (ACHTUNG es muss händisch die Url etc. angepasst werden, sonst geht das kräftig in die Hose!):Post-ID 230 wird abgearbeitet...
1. Durchlauf mit ID: 4
alte Url maxrev.de/album_pic.php?pic_id=4 wird zu: maxrev.de/album_mod/upload/2981d0d2a0b6a36962ffe24c6f8b10b4.jpg
2. Durchlauf mit ID: 5
alte Url maxrev.de/album_pic.php?pic_id=5 wird zu: maxrev.de/album_mod/upload/0d8adbf9fef0544a99ba47d4b69e64aa.jpg
...updated database.
Post-ID 232 wird abgearbeitet...
1. Durchlauf mit ID: 6
alte Url maxrev.de/album_pic.php?pic_id=6 wird zu: maxrev.de/album_mod/upload/0ac165ad2940eb3abbdc9995765aace6.jpg
...updated database.
Post-ID 249 wird abgearbeitet...
1. Durchlauf mit ID: 7
alte Url maxrev.de/album_pic.php?pic_id=7 wird zu: maxrev.de/album_mod/upload/7325bbe709ad110bc191600068f4966d.jpg
...updated database.
Post-ID 287 wird abgearbeitet...
usw.....
Code: Alles auswählen
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Get the album_pic.php-urls
//
$sql = "SELECT post_id, post_text
FROM phpbb_posts_text
WHERE post_text LIKE '%album_pic.php%'
LIMIT 0,30";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain post information.", '', __LINE__, __FILE__, $sql);
}
// Did the query return any data?
if ( $row = $db->sql_fetchrow($result) )
{
$i = 0;
do
{
$post_id = $row['post_id'];
$post_text = $row['post_text'];
echo "Post-ID $post_id wird abgearbeitet...<br />";
preg_match_all('#(deindomain.de/album_pic.php\?pic_id=)([0-9]{0,5})#i', $post_text, $treffer);
$urls = $treffer[0];
$ids = $treffer[2];
$count_ids = count($ids);
for($i = 0; $i < $count_ids; $i++)
{
echo $i + 1 . ". Durchlauf mit ID: $ids[$i] <br />";
$sql = "SELECT pic_filename
FROM phpbb_album
WHERE pic_id = " . $ids[$i];
if ( !($result2 = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain pic information.", '', __LINE__, __FILE__, $sql);
}
$row2 = $db->sql_fetchrow($result2);
$db->sql_freeresult($result2);
echo "alte Url deindomain.de/album_pic.php?pic_id=" . $ids[$i] . " wird zu: deindomain.de/album_mod/upload/" . $row2['pic_filename'] . "<br />";
$post_text = preg_replace('#(deindomain.de/album_pic.php\?pic_id=[0-9]{0,5})#i', "deindomain.de/album_mod/upload/" . $row2['pic_filename'], $post_text, 1);
}
$post_text = addslashes($post_text);
$post_text = str_replace("\'", "''", $post_text);
$post_text = str_replace('"', '\"', $post_text);
//
// Update the post text
//
$sql = "UPDATE phpbb_posts_text
SET post_text = '$post_text'
WHERE post_id = $post_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update post text.', '', __LINE__, __FILE__, $sql);
}
echo "...updated database.<br /><br />";
$i++;
}
while ( $row = $db->sql_fetchrow($result) );
$db->sql_freeresult($result);
}
?>
Code: Alles auswählen
userinfo enthält ein Array mit den folgenden Werten:
0['Array']
1['Array']
2['Array']
Code: Alles auswählen
// build fake list of personal galleries (these will get created when needed later automatically
$userinfo = album_get_nonexisting_personal_gallery_info();
print_r($userinfo);
exit;
Code: Alles auswählen
// is user allowed to create this personal gallery ?
// NOTE : that it isn't nesecary to create the $personal_gallery variable first,
// it will be generated inside the album_permissions function if needed
// but here it's done to make the code easier to read
$personal_gallery = init_personal_gallery_cat($userinfo[$idx]['user_id']);
$album_user_access = album_permissions($userinfo[$idx]['user_id'], 0, ALBUM_AUTH_CREATE_PERSONAL, $personal_gallery);
if (album_check_permission($album_user_access, ALBUM_AUTH_CREATE_PERSONAL) == TRUE)
{
$selected = (($userdata['user_id'] == $userinfo[$idx]['user_id'])) ? ' selected="selected"' : '';
$personal_gallery_list .= '<option value="-'.$userinfo[$idx]['user_id'].'" ' . $selected . '>' . sprintf($lang['Personal_Gallery_Of_User'], $userinfo[$idx]['username']) . '</option>';
}
Code: Alles auswählen
// ------------------------------------------------------------------------
// Return a list of user ids and usernames which doesn't have a personal gallery
// ------------------------------------------------------------------------
function album_get_nonexisting_personal_gallery_info()
{
global $db, $lang;
$userinfo = array();
$album_user_ids = ANONYMOUS;
// ------------------------------------------------------------------------
// sine MySQL doesn't support sub selects in select statements I have to split
// this statement up into two statements...or maybe I should try harder to do it in one ;)
// ------------------------------------------------------------------------
// first get the list of users who does have a personal gallery
$sql = "SELECT DISTINCT user_id, cat_id
FROM ". USERS_TABLE ." AS u, ". ALBUM_CAT_TABLE ." AS c
WHERE c.cat_user_id = u.user_id
AND c.cat_parent = 0";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Internal Message : Could not read user infor for fake list.', '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result) )
{
$album_user_ids .= ($album_user_ids == '') ? $row['user_id'] : ',' . $row['user_id'];
}
// get user names and user ids for info list
$sql = "SELECT user_id,username
FROM ". USERS_TABLE . "
WHERE user_id NOT IN (" . $album_user_ids .")"; // AND user_id <> " . ANONYMOUS;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Internal Message : Could not read user info for fake list.', '', __LINE__, __FILE__, $sql);
}
if ($db->sql_numrows($result) > 0)
{
while ($row = $db->sql_fetchrow($result) )
{
$userinfo[] = $row;
}
}
$db->sql_freeresult($result);
return $userinfo;
}
Code: Alles auswählen
/*
// ------------------------------------------------------------------------
// Return a list of user ids and usernames which doesn't have a personal gallery
// ------------------------------------------------------------------------
function album_get_nonexisting_personal_gallery_info()
{
global $db, $lang;
$userinfo = array();
$album_user_ids = ANONYMOUS;
// ------------------------------------------------------------------------
// sine MySQL doesn't support sub selects in select statements I have to split
// this statement up into two statements...or maybe I should try harder to do it in one ;)
// ------------------------------------------------------------------------
// first get the list of users who does have a personal gallery
$sql = "SELECT DISTINCT user_id, cat_id
FROM ". USERS_TABLE ." AS u, ". ALBUM_CAT_TABLE ." AS c
WHERE c.cat_user_id = u.user_id
AND c.cat_parent = 0";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Internal Message : Could not read user infor for fake list.', '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result) )
{
$album_user_ids .= ($album_user_ids == '') ? $row['user_id'] : ',' . $row['user_id'];
}
// get user names and user ids for info list
$sql = "SELECT user_id,username
FROM ". USERS_TABLE . "
WHERE user_id NOT IN (" . $album_user_ids .")"; // AND user_id <> " . ANONYMOUS;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Internal Message : Could not read user info for fake list.', '', __LINE__, __FILE__, $sql);
}
if ($db->sql_numrows($result) > 0)
{
while ($row = $db->sql_fetchrow($result) )
{
$userinfo[] = $row;
}
}
$db->sql_freeresult($result);
return $userinfo;
}
*/
Code: Alles auswählen
// --------------------------------
// Build categories select
// --------------------------------
//--- Album Category Hierarchy : begin
//--- version : 1.3.0
album_read_tree($userdata['user_id'], ALBUM_READ_ALL_CATEGORIES|ALBUM_AUTH_VIEW_AND_UPLOAD);
/*
// build fake list of personal galleries (these will get created when needed later automatically
$userinfo = album_get_nonexisting_personal_gallery_info();
$personal_gallery_list = '';
$count = count($userinfo);
for($idx=0; $idx < $count; $idx++)
{
// is user allowed to create this personal gallery ?
// NOTE : that it isn't nesecary to create the $personal_gallery variable first,
// it will be generated inside the album_permissions function if needed
// but here it's done to make the code easier to read
$personal_gallery = init_personal_gallery_cat($userinfo[$idx]['user_id']);
$album_user_access = album_permissions($userinfo[$idx]['user_id'], 0, ALBUM_AUTH_CREATE_PERSONAL, $personal_gallery);
if (album_check_permission($album_user_access, ALBUM_AUTH_CREATE_PERSONAL) == TRUE)
{
$selected = (($userdata['user_id'] == $userinfo[$idx]['user_id'])) ? ' selected="selected"' : '';
$personal_gallery_list .= '<option value="-'.$userinfo[$idx]['user_id'].'" ' . $selected . '>' . sprintf($lang['Personal_Gallery_Of_User'], $userinfo[$idx]['username']) . '</option>';
}
}
if (!empty($personal_gallery_list))
{
$personal_gallery_list = '<option value="'.ALBUM_JUMPBOX_SEPERATOR.'">------------------------------</option>' . $personal_gallery_list;
}
*/
$select_cat = '<select name="cat_id">';
$select_cat .= album_get_tree_option($cat_id, ALBUM_AUTH_VIEW_AND_UPLOAD);
if ( $cat_id == 0 )
{
$personal_gallery_list = '<option value="'.ALBUM_JUMPBOX_SEPERATOR.'">------------------------------</option>';
$personal_gallery_list .= '<option value="-' . $userdata['user_id'] . '" selected="selected">' . sprintf($lang['Personal_Gallery_Of_User'], $userdata['username']) . '</option>';
}
$select_cat .= $personal_gallery_list;
$select_cat .= '</select>';
// unset($personal_gallery_list);
album_free_album_data();
//--- Album Category Hierarchy : end