Thread: code help
View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01271 seconds
  • Memory Usage 1,792KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete