Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-26-2010, 06:05 PM
unknown22 unknown22 is offline
 
Join Date: Aug 2010
Posts: 114
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default code help

I have this code here:

Code:
<?php
/*
Edit the paths in line 58 and 62 accordingly. Note that these paths should be absolute, not relative.
To enable memcached, uncomment the commented blocks below (lines 22-31 and 86-89) and replace <port> with the portnumber on which memcached is listening. The default is 11211.
*/
function steam2friend($steam_id){
    $steam_id=strtolower($steam_id);
    if (substr($steam_id,0,7)=='steam_0') {
        $tmp=explode(':',$steam_id);
        if ((count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
            return bcadd((($tmp[2]*2)+$tmp[1]),'76561197960265728');
        }else return false;
    }else{
        return false;
    }
}
function get_steam_stats($id){
//uncomment the following block to enable memcached support
/*
    $mc=new Memcache;
    if (!@$mc->connect('localhost', <port>)) {
        echo 'Houston, we have a problem - the player\'s status cannot be retrieved.';
        return false;
    }

    $ret=@$mc->get('xd'.$id);
    if (!$ret){
*/
        $data=file_get_contents('http://steamcommunity.com/profiles/'.$id);
        $ret=array();
        $ret['uid']=intval($_GET['u']);
        if (strpos($data,'<h2>Private Profile</h2>')!==false) {
            $ret['private']=1;
        }else{
            if (strpos($data,'status_online.gif')!==false){
                $ret['online']=1;
            }else if (($p1=strpos($data,'<p id="statusInGameText">'))!==false){
                $p2=strpos($data,'<',$p1+25);
                $tmp=substr($data,$p1+25,$p2-$p1-25);
                $ret['ingame']=$tmp;
                $ret['join']='steam://friends/joingame/'.$id;
            }else{
                if (($p1=strpos($data,'<p id="statusOfflineText">'))!==false){
                    $p2=strpos($data,'<',$p1+26);
                    $tmp=substr($data,$p1+26,$p2-$p1-26);
                    $ret['offline']=$tmp;
                }
            }
            if (($p1=strpos($data,'<div class="avatarFull">'))!==false){
                $p1=strpos($data,'<',$p1+24);
                $p2=strpos($data,'>',$p1+1);
                $tmp=substr($data,$p1,$p2-$p1+1);
                $link_full=get_link_src($tmp);
                gaben_downloadz0r($link_full,'/absolute/path/to/forum/steamtools/icons/avatar_full'.$ret['uid'].'.jpg');
                $ret['img_full']=$tmp;
                $tmp=str_replace('_full','',$tmp);
                $link_small=get_link_src($tmp);
                gaben_downloadz0r($link_small,'/absolute/path/to/forum/steamtools/icons/avatar_small'.$ret['uid'].'.jpg');
                $ret['img_small']=$tmp;
            }
            if (($p1=strpos($data,'Steam Rating:</div>'))!==false){
                $p2=strpos($data,'<',$p1+19);
                $tmp=substr($data,$p1+19,$p2-$p1-19);
                $ret['rating']=trim($tmp);
            }
            if (($p1=strpos($data,'<h1>'))!==false){
                $p2=strpos($data,'<',$p1+4);
                $tmp=substr($data,$p1+4,$p2-$p1-4);
                $ret['steamname']=trim($tmp);
            }
            if (($p1=strpos($data,'Member since:</div>'))!==false){
                $p2=strpos($data,'<',$p1+19);
                $tmp=substr($data,$p1+19,$p2-$p1-19);
                $ret['member']=trim($tmp);
            }
            if (($p1=strpos($data,'Playing time:</div>'))!==false){
                $p2=strpos($data,'<',$p1+19);
                $tmp=substr($data,$p1+19,$p2-$p1-19);
                $ret['time']=trim($tmp);
            }
        }
//uncomment the following block to enable memcached support
/*
        @$mc->set('xd'.$id,$ret,MEMCACHE_COMPRESSED,300);
    }
*/
    return $ret;
}
function get_link_src($data){
    $p1=strpos($data,chr(34));
    $p2=strpos($data,chr(34),$p1+1);
    return substr($data,$p1+1,$p2-$p1-1);
}
function gaben_downloadz0r ($url,$target){
    $data=file_get_contents($url);
    if ($data) {
        file_put_contents($target,$data);
    }
}
?>
But when I enable it says

Code:
Warning: file_put_contents(/absolute/path/to/forum/steamtools/icons/avatar_full1.jpg) [function.file-put-contents]: failed to open stream: No such file or directory in [path]/steamtools/steam_function.php on line 100

Warning: file_put_contents(/absolute/path/to/forum/steamtools/icons/avatar_small1.jpg) [function.file-put-contents]: failed to open stream: No such file or directory in [path]/steamtools/steam_function.php on line 100
I asked how I could fix this and someone just said use this
print SERVER['DOCUMENT_ROOT']

I dont know what it means can anyone help?

Install instructions but i dont get why its not working
Code:
1. create a subfolder named 'steamtools' in the folder where your forum (index.php) resides
2. create a subfolder in 'steamtools' named 'icons'
3. chmod 'icons' to 755
4. open steam_function.php in a plain text editor like notepad, and replace the paths in lines 58 and 62 accordingly. Note that these paths need to be absolute and not relative!
5. upload steam_function.php to 'steamtools'
6. create a sinlge-line text box custom profile field named 'Steam ID' (note this is case sensitive, if you want to change this, change the occurring instances in the .xml and .php files as well)
7. create a single-selection radio buttons custom profile field named 'Steam Community' with these two values : 'Yes, make the links visible' and 'No, hide the links' (note this is all case sensitive, if you want to change this, change the occurring instances in the .xml and .php files as well)
8. import product-steam2friends.xml in the admin panel
Reply With Quote
  #2  
Old 09-26-2010, 06:23 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you actually leave this in your code?
HTML Code:
/absolute/path/to/forum/steamtools/icons/avatar_full
If so, that is your problem. You are supposed to change that to be your absolute path.
Reply With Quote
  #3  
Old 09-26-2010, 09:28 PM
unknown22 unknown22 is offline
 
Join Date: Aug 2010
Posts: 114
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yea sorry that's what I did not understand what does that mean?

open steam_function.php in a plain text editor like notepad, and replace the paths in lines 58 and 62 accordingly. Note that these paths need to be absolute and not relative!

Edit the paths in line 58 and 62 accordingly. Note that these paths should be absolute, not relative.
To enable memcached, uncomment the commented blocks below (lines 22-31 and 86-89) and replace <port> with the portnumber on which memcached is listening. The default is 11211.

How do I fix that?
Reply With Quote
  #4  
Old 09-27-2010, 04:01 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ever server has a path to a file. You start at the very top and go down via directories (just like on your computer). So, it's the path from the top. You start at the top, then go into a directory called "home", then from there to "sitename", then from there to "public_html", then from there to.... etc. So far, the path in that example is /home/sitename/public_html/
Reply With Quote
  #5  
Old 09-27-2010, 05:25 PM
unknown22 unknown22 is offline
 
Join Date: Aug 2010
Posts: 114
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh ok thanks,

On here though I have my paths down correctly but shows the links no pictures

Code:
            if (($p1=strpos($data,'<div class="avatarFull">'))!==false){
                $p1=strpos($data,'<',$p1+24);
                $p2=strpos($data,'>',$p1+1);
                $tmp=substr($data,$p1,$p2-$p1+1);
                $link_full=get_link_src($tmp);
                gaben_downloadz0r($link_full,'/home/users/public_html/forums/steamtools/icons/avatar_full'.$ret['uid'].'.jpg');
                $ret['img_full']=$tmp;
                $tmp=str_replace('_full','',$tmp);
                $link_small=get_link_src($tmp);
                gaben_downloadz0r($link_small,'/home/users/public_html/forums/steamtools/icons/avatar_small'.$ret['uid'].'.jpg');
                $ret['img_small']=$tmp;
But it said correct lines on 58 and 62 which is

Line 58: ['img_full']

Line 62: ['img_small']
Reply With Quote
  #6  
Old 09-27-2010, 05:59 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If the script isn't working after you got the paths correct, then you really should be asking them for help. I know absolutely nothing about that script.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:27 PM.


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.03708 seconds
  • Memory Usage 2,218KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete