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]   Go Down

Author Topic: using avatar on non coppermine?.  (Read 4018 times)

0 Members and 1 Guest are viewing this topic.

Justttt

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 170
    • Trippy-ILLusion.Co.Uk
using avatar on non coppermine?.
« on: June 22, 2006, 12:40:22 pm »

hey , i have searched the fourms and no look , i would lyk to display the avatar on a non coppermine page if this is possible. can anybody help please


thanks , justttt
« Last Edit: June 22, 2006, 07:25:28 pm by GauGau »
Logged
J U S T T T T

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: using avatar on non coppermine?.
« Reply #1 on: June 22, 2006, 12:50:49 pm »

Avatar!!!!?
what avatar?
if you want to insert pic from coppermine to non coppermine page use CPMfetch MOD
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Justttt

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 170
    • Trippy-ILLusion.Co.Uk
Re: using avatar on non coppermine?.
« Reply #2 on: June 22, 2006, 01:00:37 pm »

the avatar what shows in posted comments, profile. i would like it to be shown on another page beacause i would like to create a userpanel. and at the top would like the user to see the avatar and link under it saying "change avatar"

thanks , justttt
Logged
J U S T T T T

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: using avatar on non coppermine?.
« Reply #3 on: June 22, 2006, 01:11:31 pm »

if you are speaking about mod pack avatar then this isn't Right board to ask you should ask this on Mod Pack board
« Last Edit: June 22, 2006, 01:36:00 pm by bmossavari »
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Justttt

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 170
    • Trippy-ILLusion.Co.Uk
Re: using avatar on non coppermine?.
« Reply #4 on: June 22, 2006, 01:23:53 pm »

ok , thank's
Logged
J U S T T T T

Justttt

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 170
    • Trippy-ILLusion.Co.Uk
Re: using avatar on non coppermine?.
« Reply #5 on: June 22, 2006, 05:40:43 pm »

i have the code working , demo -> http://www.y-idols.com/justttt/gall/avatar.php

but i no all the code thats still in there is not nessesury could someone please help me shorten it to what i need ? .


Code: [Select]
<?php
define
('IN_COPPERMINE'true);
define('UPLOAD_PHP'true);
define('DB_INPUT_PHP'true);
define('CONFIG_PHP'true);
define('AVATAR_PHP'true); //language file
require('include/init.inc.php');
require(
'include/picmgmt.inc.php');

if (!
USER_IDcpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);

$event = isset($_REQUEST['event']) ? $_REQUEST['event'] : null;
switch (
$event) {

    case 
'picture':

        if (!
USER_CAN_UPLOAD_PICTUREScpg_die(ERROR$lang_errors['perm_denied'], __FILE____LINE__);
        
// Test if the filename of the temporary uploaded picture is empty
        
if ($_FILES['userpicture']['tmp_name'] == ''cpg_die(ERROR$lang_db_input_php['no_pic_uploaded'], __FILE____LINE__);
        
// Pictures are moved in a directory named 10000 + USER_ID


$mime_content cpg_get_type($_FILES['userpicture']['name']);
if ($mime_content['content'] != 'image' cpg_die(ERROR"Error, please upload an image, this is "$mime_content['content'], __FILE____LINE__);

        if (
USER_ID && !defined('SILLY_SAFE_MODE')) {
            
$filepath $CONFIG['userpics'] . (USER_ID FIRST_USER_CAT);
            
$dest_dir $CONFIG['fullpath'] . $filepath;
            if (!
is_dir($dest_dir)) {
                
mkdir($dest_diroctdec($CONFIG['default_dir_mode']));
                if (!
is_dir($dest_dir)) cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['err_mkdir'], $dest_dir), __FILE____LINE__true);
                
chmod($dest_diroctdec($CONFIG['default_dir_mode']));
                
$fp fopen($dest_dir '/index.html''w');
                
fwrite($fp' ');
                
fclose($fp);
            }
            
$dest_dir .= '/';
            
$filepath .= '/';
        } else {
            
$filepath $CONFIG['userpics'];
            
$dest_dir $CONFIG['fullpath'] . $filepath;
        }
        
// Check that target dir is writable
        
if (!is_writable($dest_dir)) cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['dest_dir_ro'], $dest_dir), __FILE____LINE__true);
        
// Replace forbidden chars with underscores
        
$matches = array();
        
$forbidden_chars strtr($CONFIG['forbiden_fname_char'], array('&amp;' => '&''&quot;' => '"''&lt;' => '<''&gt;' => '>'));
        
// Check that the file uploaded has a valid extension
        
if (get_magic_quotes_gpc()) $_FILES['userpicture']['name'] = stripslashes($_FILES['userpicture']['name']);
        
$picture_name strtr($_FILES['userpicture']['name'], $forbidden_charsstr_repeat('_'strlen($CONFIG['forbiden_fname_char'])));
        if (!
preg_match("/(.+)\.(.*?)\Z/"$picture_name$matches)) {
            
$matches[1] = 'invalid_fname';
            
$matches[2] = 'xxx';
        }

        if (
$matches[2] == '' || !is_known_filetype($matches)) {
            
cpg_die(ERRORsprintf($lang_db_input_php['err_invalid_fext'], $CONFIG['allowed_file_extensions']), __FILE____LINE__);
        }

        
// Create a unique name for the uploaded file
        
$nr 0;
        
$picture_name $matches[1] . '.' $matches[2];
$avatar_name 'user_'.(USER_ID FIRST_USER_CAT).'_avatar.' $matches[2];
        while (
file_exists($dest_dir $picture_name)) {
            
$picture_name $matches[1] . '~' $nr++ . '.' $matches[2];
        }
        
$uploaded_pic $dest_dir $picture_name;
        
// Move the picture into its final location
        
if (!move_uploaded_file($_FILES['userpicture']['tmp_name'], $uploaded_pic))
            
cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['err_move'], $picture_name$dest_dir), __FILE____LINE__true);
        
// Change file permission
        
chmod($uploaded_picoctdec($CONFIG['default_file_mode']));
        
// Get picture information


        // Check that picture file size is lower than the maximum allowed
        
if (filesize($uploaded_pic) > ($CONFIG['max_upl_size'] << 10)) {
            @
unlink($uploaded_pic);
            
cpg_die(ERRORsprintf($lang_db_input_php['err_imgsize_too_large'], $CONFIG['max_upl_size']), __FILE____LINE__);
        } elseif (
is_image($picture_name)) {
            
$imginfo getimagesize($uploaded_pic);
            
// getimagesize does not recognize the file as a picture
            
if ($imginfo == null) {
                @
unlink($uploaded_pic);
                
cpg_die(ERROR$lang_db_input_php['err_invalid_img'], __FILE____LINE__true);
            
// JPEG and PNG only are allowed with GD
            
} elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && $imginfo[2] != GIS_GIF && ($CONFIG['thumb_method'] == 'gd1' || $CONFIG['thumb_method'] == 'gd2')) {
                @
unlink($uploaded_pic);
                
cpg_die(ERROR$lang_errors['gd_file_type_err'], __FILE____LINE__true);
            } elseif (
max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
                @
unlink($uploaded_pic);
                
cpg_die(ERRORsprintf($lang_db_input_php['err_fsize_too_large'], $CONFIG['max_upl_width_height'], $CONFIG['max_upl_width_height']), __FILE____LINE__);
            } 
// Image is ok
        
}

    
$work_image $CONFIG['fullpath'] . $filepath $picture_name;
$avatar $CONFIG['fullpath'] . $filepath $avatar_name;
            if (!
resize_image($work_image$avatar$CONFIG['mini_thumb_width'], $CONFIG['thumb_method'], "mini""false"1))
{
      @unlink($uploaded_pic);
            
cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['err_insert_pic'], $uploaded_pic) . '<br /><br />' $ERROR__FILE____LINE__true);
        
        } else {
cpg_db_query("UPDATE {$CONFIG['TABLE_USERS']} SET avatar_url='".$avatar."' WHERE user_id='".(USER_ID)."'");
//not used anymore due to bridge compatibility
//cpg_db_query("UPDATE {$CONFIG['TABLE_COMMENTS']} SET avatar_url='".$avatar."' WHERE author_id='".(USER_ID)."'");

@unlink($uploaded_pic);
            
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/'getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' 'Location: ';
            
$redirect "avatar_manage.php";
            
header($header_location $redirect);
            
pageheader($lang_info"<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
            
msg_box($lang_info$lang_db_input_php['upl_success'], $lang_continue$redirect);
            
pagefooter();
            
ob_end_flush();
            exit;
        }
break;
}




if(isset(
$_POST['dowhat']))
{

switch ($_POST['dowhat']) {
case "delete_avatar":
if (isset($_POST['all_avatar'])) { //confirm checkbox clicked??
//first let's check if an uploaded avatar is in his folder
$result cpg_db_query("SELECT avatar_url FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '".(USER_ID)."'");
$url_data mysql_fetch_array($result);
mysql_free_result($result);
$avatar_url $url_data['avatar_url'];
@unlink($avatar_url);

cpg_db_query("UPDATE {$CONFIG['TABLE_USERS']} SET avatar_url='' WHERE user_id='".(USER_ID)."'");
//not used anymore due to bridge compatibility
//cpg_db_query("UPDATE {$CONFIG['TABLE_COMMENTS']} SET avatar_url='' WHERE author_id='".(USER_ID)."'");
header('Location: '.$PHP_SELF);
}
    break;
case "set_avatar":
$mark_list=$_POST['list'];
if ($marklist[0]) header('Location: http://localhost');
while(list($key$value) = each($mark_list)) 
if ($key
{
cpg_db_query("UPDATE {$CONFIG['TABLE_USERS']} SET avatar_url='".$CONFIG['fullpath'].$key."' WHERE user_id='".(USER_ID)."'");
//not used anymore due to bridge compatibility
//cpg_db_query("UPDATE {$CONFIG['TABLE_COMMENTS']} SET avatar_url='".$CONFIG['fullpath'].$key."' WHERE author_id='".(USER_ID)."'");
}
header('Location: '.$PHP_SELF);
   break;
}

}

$result cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_PICTURES']} WHERE owner_id=".(USER_ID));
list(
$tot_pictures) = @mysql_fetch_array($result);

$result cpg_db_query("SELECT avatar_url FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '".(USER_ID)."'");
$url_data mysql_fetch_array($result);
mysql_free_result($result);
$avatar_url $url_data['avatar_url'];
if (
$avatar_url !=""$avatar_url "<img src='".$avatar_url."' class=\"image\">";
else 
$avatar_url="";



pageheader($lang_avatar['manage']);
starttable(check);
echo <<<EOT






<fieldset class="fieldset">
<div align="right">
  <legend>
$avatar_url</legend>
</div>
<table cellpadding="0" cellspacing="3" border="0">


EOT;



endtable();


pagefooter();
ob_end_flush();




/* ################################################################################################ */
function clean_table() {
    global 
$CONFIG;
    
$comparative_timestamp time() - 3600;
    
$result mysql_query("DELETE FROM {$CONFIG['TABLE_TEMPDATA']} WHERE timestamp < $comparative_timestamp");
    if (
$result) {
        return 
TRUE;
    } else {
        return 
FALSE;
    }
}


function 
hidden_input($name$value) {
        echo 
"        <input type=\"hidden\" name=\"$name\" value=\"$value\">\n";
}


function 
file_input($text$name$iterations) {

    
$ordinal '';

    
// Begin loop
    
for ($counter=0$counter<$iterations$counter++) {

    
// Create a numbering system when necessary.
    
if ($text == '') {
        
$cardinal $counter 1;
        
$ordinal "".$cardinal.". ";
    }

    
// Create the file input box.
    
echo <<<EOT
        <tr>
            <td class="tableb">
                        
$text  $ordinal
        </td>
        <td class="tableb" valign="top">
                        <input type="file" name="
$name" size="40" class="listbox">
                </td>
        </tr>

EOT;
    }
}

function 
create_form(&$data) {
    global 
$CONFIG;
    foreach(
$data as $element) {
        if ((
is_array($element))) {
            switch (
$element[2]) {
                case 
:
                    
text_box_input($element[0], $element[1], $element[3], $element[4]);
                    break;
                case 
:
                    
file_input($element[0], $element[1], $element[3]);
                    break;
                case 
:
                    
form_alb_list_box($element[0], $element[1]);
                    break;
                case 
:
                    
text_area_input($element[0], $element[1], $element[3]);
                    break;
                case 
:
                    
hidden_input($element[0], $element[1]);
                    break;
                default:
                    
cpg_die(ERROR$lang_upload_php['reg_instr_1'], __FILE____LINE__);
            } 
// switch
        
} else {
            
form_label($element);
        }
    }
}

function 
form_label($text) {
    echo <<<EOT
        <tr>
                <td class="tableh2" colspan="2">
                        <b>
$text</b>
                </td>
        </tr>

EOT;
}

function 
open_form($path) {

    echo <<<EOT
    <script language="JavaScript">
    function textCounter(field, maxlimit) {
            if (field.value.length > maxlimit) // if too long...trim it!
            field.value = field.value.substring(0, maxlimit);
    }
    </script>
    <form method="post" action="
$path" ENCTYPE="multipart/form-data">
    </td>
EOT;
}


function 
close_form($button_value) {
global 
$lang_upload_php;
echo <<<EOT
        <tr>
                <td colspan="2" align="right" class="tablef">
                        <input type="submit" value="
{$button_value}" class="button">
                </td>
                </form>
        </tr>

EOT;
}


function 
form_instructions() {

    global 
$CONFIG$lang_upload_php$user_form$max_file_size;

    echo 
"<tr><td colspan=2><br />";

    
printf ($lang_upload_php['avatar_instr_1'], $CONFIG['max_upl_size']);

    echo 
"</td></tr>";

}





function 
create_avatar_upload ()
{
global $lang_upload_php$CONFIG$max_file_size;
    
// Do some cleanup in the edit directory.
    
spring_cleaning('./albums/edit',3600);

    
// Do some cleaning in the temp data table.
    
clean_table();

    
// Create upload form headers.
    //pageheader($lang_upload_php['title']);

    // Open the form table.
    //starttable("100%", $lang_upload_php['title'], 2);
 
 
        // The user has the single upload only form. Send the request to db_input.php.
        
open_form($_SERVER['PHP_SELF']);
        
//open_form('upload_avatar.php');
        
form_instructions();
 
 
 
 
         
// The user should have the 'single upload only' form.

        // Declare an array containing the various upload form box definitions.
        
$captionLabel $lang_upload_php['description'];
        
$form_array = array(
        
sprintf($lang_upload_php['max_fsize'], $CONFIG['max_upl_size']),
        array(
'MAX_FILE_SIZE'$max_file_size4),
        array(
$lang_upload_php['picture'], 'userpicture'11),
        array(
'event''picture'4)
        );


 
 
 
 
     
create_form($form_array);
 
 
        
// The user has the single upload only form. Select proper language for button.
        
close_form($lang_upload_php['title']);

    //endtable();
    //pagefooter();
    //ob_end_flush();

    // Exit the script.

    //exit;
}


?>
Logged
J U S T T T T

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: using avatar on non coppermine?.
« Reply #6 on: June 22, 2006, 07:06:23 pm »

You've been told already that the mod pack doesn't get supported on the regular support board, so I'm locking this thread now.
Logged
Pages: [1]   Go Up
 

Page created in 0.039 seconds with 20 queries.