vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   code help (https://vborg.vbsupport.ru/showthread.php?t=251195)

unknown22 09-26-2010 06:05 PM

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


Lynne 09-26-2010 06:23 PM

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.

unknown22 09-26-2010 09:28 PM

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?

Lynne 09-27-2010 04:01 AM

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/

unknown22 09-27-2010 05:25 PM

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']

Lynne 09-27-2010 05:59 PM

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.


All times are GMT. The time now is 06:30 AM.

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.01136 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete