Jump to content

Need some code help >.<


F0XTR0T

Recommended Posts

So im working on a code that is rather long i guess. the problem im having is that it needs to pull some information from 2 sites and load it on to a image. it will pull information from one site and load it correctly. but not for the second.

<?php
//Simple siggy example.
header("Content-type: image/png");//tell the browser what content to expect.

$url = "http://shadowscripting.org/iDungeon/makeSiggies/siggy.php?name=All%20Users&5=siggy5.png&lite=true";//replace all spaces with "%20".
$url1 ="http://hiscore.runescape.com/index_lite.ws?player=zezima";
$str = file($url);
$str1 = file($url1);
$split = explode("|", $str[0]);
$split1 = explode(",", $str1[0]);
//casted to a float from a string, because you people botted more xp than 32-bit servers can hold in an integer!
$tokens = (float)$split[0];
$xp = (float)$split[1];
$completed = (float)$split[2];
$time = (float)$split[3];
$rank = (float)$split[4];
$message = (float)$split[5];
$s1 = (float)$split1[49];

$im = imagecreate(607, 162);//for this example, we'll create a blank image.
$im     = imagecreatefrompng("Gladly's Siggy.png");//use this to load a background image instead.
imagealphablending($im, true); // setting alpha blending on - leave this in.
imagesavealpha($im, true); // save alphablending setting - leave this alone too.

$textColor = imagecolorallocate($im, 0, 0, 0);//set up a color to use for the text.
$bkgColor = imagecolorallocate($im, 0, 0, 0);//set up a random color for the background. (Not needed if you use a background image)
//fill the image background:
imagefill($im, 0, 0, $bkgColor);//also not needed if you use a background image.

imagettftext($im, 18, 0, 57, 200, $textColor, "./imagine_font.ttf", "".number_format($s1));
imagettftext($im, 18, 0, 120, 200, $textColor, "./imagine_font.ttf", "00");
imagettftext($im, 18, 0, 180, 200, $textColor, "./imagine_font.ttf", "00");
imagettftext($im, 18, 0, 250, 200, $textColor, "./imagine_font.ttf", "00");
imagettftext($im, 13, 0, 340, 152, $textColor, "./imagine_font.ttf", "".number_format($xp));
imagettftext($im, 13, 0, 340, 170, $textColor, "./imagine_font.ttf", "".number_format($tokens));
imagettftext($im, 13, 0, 340, 132, $textColor, "./imagine_font.ttf", "".number_format($completed));
imagettftext($im, 13, 0, 340, 116, $textColor, "./imagine_font.ttf", "".sec2hms($time));


imagepng($im);//output the image to the browser!
imagedestroy($im);//clean it from the system memory.

//you can ignore the below function. It's simply here to convert the time.
function sec2hms ($sec, $padHours = true) {
//Function in this example created by Coggla @ http://snipplr.com/view/4688/convert-seconds-to-hhmmss/
// You'll probably want to make your own function.
    $hms = "";

    // there are 3600 seconds in an hour, so if we
    // divide total seconds by 3600 and throw away
    // the remainder, we've got the number of hours
    $hours = intval(intval($sec) / 3600); 

    // add to $hms, with a leading 0 if asked for
    $hms .= ($padHours) 
          ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':'
          : $hours. ':';

    // dividing the total seconds by 60 will give us
    // the number of minutes, but we're interested in 
    // minutes past the hour: to get that, we need to 
    // divide by 60 again and keep the remainder
    $minutes = intval(($sec / 60) % 60); 

    // then add to $hms (with a leading 0 if needed)
    $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';

    // seconds are simple - just divide the total
    // seconds by 60 and keep the remainder
    $seconds = intval($sec % 60); 

    // add to $hms, again with a leading 0 if needed
    $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);

    return $hms;
}

?>

anyone see a problem?

Link to comment
Share on other sites

What exactly doesn't work? Echo out the strings before you put them onto an image and see what you get.

Gladly.php

thats the image that im editing with php.

if you notice the single 0 next to the ring, it is supposed to be a 89. what isnt working is well, the stat isnt getting added correctly, and it wont update like everything else is.

lets be a little more specific. the "time ran, dungeons completed, total xp, and total tokens" are being updated by $url

Everything else, will be updated by $url1

$url1 is what im having a problem with

Link to comment
Share on other sites

I tried your code and echoed out the split array of url1:

 

Array

(

    [0] => 26

    [1] => 2496

    [2] => 1452986741

1047

    [3] => 99

    [4] => 67289856

832

    [5] => 99

    [6] => 59403539

4439

    [7] => 99

    [8] => 43517481

789

    [9] => 99

    [10] => 66642357

1212

    [11] => 99

    [12] => 37853433

1034

    [13] => 99

    [14] => 14790273

84

    [15] => 99

    [16] => 67499520

5

    [17] => 99

    [18] => 200000000

3216

    [19] => 99

    [20] => 25391207

74

    [21] => 99

    [22] => 150021891

1644

    [23] => 99

    [24] => 29627289

46

    [25] => 99

    [26] => 118777158

133

    [27] => 99

    [28] => 33158882

533

    [29] => 99

    [30] => 20629594

2962

    [31] => 99

    [32] => 17689939

42

    [33] => 99

    [34] => 62791665

2357

    [35] => 99

    [36] => 14780316

5

    [37] => 99

    [38] => 200000000

2991

    [39] => 99

    [40] => 19305640

507

    [41] => 99

    [42] => 29647401

3626

    [43] => 99

    [44] => 16798671

15711

    [45] => 99

    [46] => 13767830

1036

    [47] => 99

    [48] => 17163832

5880

    [49] => 99

    [50] => 13910370

590

    [51] => 120

    [52] => 112528597

2846

    [53] => 1944

-1

    [54] => -1

-1

    [55] => -1

-1

    [56] => -1

-1

    [57] => -1

4356

    [58] => 3988

3743

    [59] => 3987

2538

    [60] => 4148

5571

    [61] => 4105

-1

    [62] => -1

-1

    [63] => -1

 

)

 

Basically [49] contains "99", not 89. Why do you need to float the numbers? They're all integers...

Link to comment
Share on other sites

I tried your code and echoed out the split array of url1:

 

Array

(

    [0] => 26

    [1] => 2496

    [2] => 1452986741

1047

    [3] => 99

    [4] => 67289856

832

    [5] => 99

    [6] => 59403539

4439

    [7] => 99

    [8] => 43517481

789

    [9] => 99

    [10] => 66642357

1212

    [11] => 99

    [12] => 37853433

1034

    [13] => 99

    [14] => 14790273

84

    [15] => 99

    [16] => 67499520

5

    [17] => 99

    [18] => 200000000

3216

    [19] => 99

    [20] => 25391207

74

    [21] => 99

    [22] => 150021891

1644

    [23] => 99

    [24] => 29627289

46

    [25] => 99

    [26] => 118777158

133

    [27] => 99

    [28] => 33158882

533

    [29] => 99

    [30] => 20629594

2962

    [31] => 99

    [32] => 17689939

42

    [33] => 99

    [34] => 62791665

2357

    [35] => 99

    [36] => 14780316

5

    [37] => 99

    [38] => 200000000

2991

    [39] => 99

    [40] => 19305640

507

    [41] => 99

    [42] => 29647401

3626

    [43] => 99

    [44] => 16798671

15711

    [45] => 99

    [46] => 13767830

1036

    [47] => 99

    [48] => 17163832

5880

    [49] => 99

    [50] => 13910370

590

    [51] => 120

    [52] => 112528597

2846

    [53] => 1944

-1

    [54] => -1

-1

    [55] => -1

-1

    [56] => -1

-1

    [57] => -1

4356

    [58] => 3988

3743

    [59] => 3987

2538

    [60] => 4148

5571

    [61] => 4105

-1

    [62] => -1

-1

    [63] => -1

 

)

 

Basically [49] contains "99", not 89. Why do you need to float the numbers? They're all integers...

Sorry about that, the link givin is to the wrong database. I updated my actual php without updating this one the real link is http://hiscore.runescape.com/index_lite.ws?player=69b which would still imply that 51 is the correct interger. let me make a few modifications to my php, and update the image.

Edit: i tried with 51 and didnt float the numbers, and nothing.

Link to comment
Share on other sites

I tried your code and it worked properly. You don't need to float, man. Btw your directory is public, really bad idea.

 

He has 71 not 51.

who has 71 not 51? and um, im stupid in php, could you post what you changed so i can learn.

And idk how to make 000webhost private.

Link to comment
Share on other sites

69b.

 

Check your PM for my site with your code - worked perfectly.

 

Wow NICE! but i dont get why mine doesnt work but yours does.

could you post the code you used in

 brackets so i could see it?

Its making me monder on what i did wrong

Link to comment
Share on other sites

Can you post your updated code first?

it isnt really updated. i just changed a few things that i was were wrong

<?php
//Simple siggy example.
header("Content-type: image/png");//tell the browser what content to expect.

$url = "http://shadowscripting.org/iDungeon/makeSiggies/siggy.php?name=Gladly&5=siggy5.png&lite=true";//replace all spaces with "%20".
$url1 ="http://hiscore.runescape.com/index_lite.ws?player=69b";
$str = file($url);
$str1 = file($url1);
$split = explode("|", $str[0]);
$split1 = explode(",", $str1[0]);
//casted to a float from a string, because you people botted more xp than 32-bit servers can hold in an integer!
$tokens = (float)$split[0];
$xp = (float)$split[1];
$completed = (float)$split[2];
$time = (float)$split[3];
$rank = (float)$split[4];
$message = (float)$split[5];
$s1 = $split1[51];

$im = imagecreate(607, 162);//for this example, we'll create a blank image.
$im     = imagecreatefrompng("Gladly's Siggy.png");//use this to load a background image instead.
imagealphablending($im, true); // setting alpha blending on - leave this in.
imagesavealpha($im, true); // save alphablending setting - leave this alone too.

$textColor = imagecolorallocate($im, 0, 0, 0);//set up a color to use for the text.
$bkgColor = imagecolorallocate($im, 0, 0, 0);//set up a random color for the background. (Not needed if you use a background image)
//fill the image background:
imagefill($im, 0, 0, $bkgColor);//also not needed if you use a background image.

imagettftext($im, 18, 0, 57, 200, $textColor, "./imagine_font.ttf", "".number_format($s1));
imagettftext($im, 18, 0, 120, 200, $textColor, "./imagine_font.ttf", "00");
imagettftext($im, 18, 0, 180, 200, $textColor, "./imagine_font.ttf", "00");
imagettftext($im, 18, 0, 250, 200, $textColor, "./imagine_font.ttf", "00");
imagettftext($im, 13, 0, 340, 152, $textColor, "./imagine_font.ttf", "".number_format($xp));
imagettftext($im, 13, 0, 340, 170, $textColor, "./imagine_font.ttf", "".number_format($tokens));
imagettftext($im, 13, 0, 340, 132, $textColor, "./imagine_font.ttf", "".number_format($completed));
imagettftext($im, 13, 0, 340, 116, $textColor, "./imagine_font.ttf", "".sec2hms($time));


imagepng($im);//output the image to the browser!
imagedestroy($im);//clean it from the system memory.

//you can ignore the below function. It's simply here to convert the time.
function sec2hms ($sec, $padHours = true) {
//Function in this example created by Coggla @ http://snipplr.com/view/4688/convert-seconds-to-hhmmss/
// You'll probably want to make your own function.
    $hms = "";

    // there are 3600 seconds in an hour, so if we
    // divide total seconds by 3600 and throw away
    // the remainder, we've got the number of hours
    $hours = intval(intval($sec) / 3600); 

    // add to $hms, with a leading 0 if asked for
    $hms .= ($padHours) 
          ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':'
          : $hours. ':';

    // dividing the total seconds by 60 will give us
    // the number of minutes, but we're interested in 
    // minutes past the hour: to get that, we need to 
    // divide by 60 again and keep the remainder
    $minutes = intval(($sec / 60) % 60); 

    // then add to $hms (with a leading 0 if needed)
    $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';

    // seconds are simple - just divide the total
    // seconds by 60 and keep the remainder
    $seconds = intval($sec % 60); 

    // add to $hms, again with a leading 0 if needed
    $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);

    return $hms;
}

?>

Link to comment
Share on other sites

Do you have access to cURL? Or at least don't use the file() function it first splits the string by new line.

 

Try debugging by using print_r($str1) and tell me what you get. I never used the file() function. It gives you bad control of what you read.

Link to comment
Share on other sites

This just made me cry a little, first he posts an absurdly long post, without code tags to break it down and make it formatted a bit better and then you quote it.

 

*premiso is ashamed and crawls into a hole to try and easy the shame.

 

I tried your code and echoed out the split array of url1:

 

Array

(

    [0] => 26

    [1] => 2496

    [2] => 1452986741

1047

    [3] => 99

    [4] => 67289856

832

    [5] => 99

    [6] => 59403539

4439

    [7] => 99

    [8] => 43517481

789

    [9] => 99

    [10] => 66642357

1212

    [11] => 99

    [12] => 37853433

1034

    [13] => 99

    [14] => 14790273

84

    [15] => 99

    [16] => 67499520

5

    [17] => 99

    [18] => 200000000

3216

    [19] => 99

    [20] => 25391207

74

    [21] => 99

    [22] => 150021891

1644

    [23] => 99

    [24] => 29627289

46

    [25] => 99

    [26] => 118777158

133

    [27] => 99

    [28] => 33158882

533

    [29] => 99

    [30] => 20629594

2962

    [31] => 99

    [32] => 17689939

42

    [33] => 99

    [34] => 62791665

2357

    [35] => 99

    [36] => 14780316

5

    [37] => 99

    [38] => 200000000

2991

    [39] => 99

    [40] => 19305640

507

    [41] => 99

    [42] => 29647401

3626

    [43] => 99

    [44] => 16798671

15711

    [45] => 99

    [46] => 13767830

1036

    [47] => 99

    [48] => 17163832

5880

    [49] => 99

    [50] => 13910370

590

    [51] => 120

    [52] => 112528597

2846

    [53] => 1944

-1

    [54] => -1

-1

    [55] => -1

-1

    [56] => -1

-1

    [57] => -1

4356

    [58] => 3988

3743

    [59] => 3987

2538

    [60] => 4148

5571

    [61] => 4105

-1

    [62] => -1

-1

    [63] => -1

 

)

 

Basically [49] contains "99", not 89. Why do you need to float the numbers? They're all integers...

Sorry about that, the link givin is to the wrong database. I updated my actual php without updating this one the real link is http://hiscore.runescape.com/index_lite.ws?player=69b which would still imply that 51 is the correct interger. let me make a few modifications to my php, and update the image.

Edit: i tried with 51 and didnt float the numbers, and nothing.

Link to comment
Share on other sites

Do you have access to cURL? Or at least don't use the file() function it first splits the string by new line.

 

Try debugging by using print_r($str1) and tell me what you get. I never used the file() function. It gives you bad control of what you read.

Yeah, im confused  :wtf::confused:

like i said, im not the best at this stuff

Link to comment
Share on other sites

This just made me cry a little, first he posts an absurdly long post, without code tags to break it down and make it formatted a bit better and then you quote it.

 

*premiso is ashamed and crawls into a hole to try and easy the shame.

 

[quote author=F0XTR0T link=topic=338672.msg1596039#msg1596039 date=1310649137]
[quote author=silkfire link=topic=338672.msg1596037#msg1596037 date=1310648948]
I tried your code and echoed out the split array of url1:

Array
(
    [0] => 26
    [1] => 2496
    [2] => 1452986741
1047
    [3] => 99
    [4] => 67289856
832
    [5] => 99
    [6] => 59403539
4439
    [7] => 99
    [8] => 43517481
789
    [9] => 99
    [10] => 66642357
1212
    [11] => 99
    [12] => 37853433
1034
    [13] => 99
    [14] => 14790273
84
    [15] => 99
    [16] => 67499520
5
    [17] => 99
    [18] => 200000000
3216
    [19] => 99
    [20] => 25391207
74
    [21] => 99
    [22] => 150021891
1644
    [23] => 99
    [24] => 29627289
46
    [25] => 99
    [26] => 118777158
133
    [27] => 99
    [28] => 33158882
533
    [29] => 99
    [30] => 20629594
2962
    [31] => 99
    [32] => 17689939
42
    [33] => 99
    [34] => 62791665
2357
    [35] => 99
    [36] => 14780316
5
    [37] => 99
    [38] => 200000000
2991
    [39] => 99
    [40] => 19305640
507
    [41] => 99
    [42] => 29647401
3626
    [43] => 99
    [44] => 16798671
15711
    [45] => 99
    [46] => 13767830
1036
    [47] => 99
    [48] => 17163832
5880
    [b][49] => 99[/b]
    [50] => 13910370
590
    [51] => 120
    [52] => 112528597
2846
    [53] => 1944
-1
    [54] => -1
-1
    [55] => -1
-1
    [56] => -1
-1
    [57] => -1
4356
    [58] => 3988
3743
    [59] => 3987
2538
    [60] => 4148
5571
    [61] => 4105
-1
    [62] => -1
-1
    [63] => -1

)

Basically [49] contains "99", not 89. Why do you need to float the numbers? They're all integers...
[/quote]
Sorry about that, the link givin is to the wrong database. I updated my actual php without updating this one the real link is [url=http://hiscore.runescape.com/index_lite.ws?player=69b]http://hiscore.runescape.com/index_lite.ws?player=69b[/url] which would still imply that 51 is the correct interger. let me make a few modifications to my php, and update the image.
Edit: i tried with 51 and didnt float the numbers, and nothing.
[/quote]

 

as you quote both of us, good one

Link to comment
Share on other sites

Just to make a point, maybe it will stick :)

 

w00t another full quote!

 

This just made me cry a little, first he posts an absurdly long post, without code tags to break it down and make it formatted a bit better and then you quote it.

 

*premiso is ashamed and crawls into a hole to try and easy the shame.

 

[quote author=F0XTR0T link=topic=338672.msg1596039#msg1596039 date=1310649137]
[quote author=silkfire link=topic=338672.msg1596037#msg1596037 date=1310648948]
I tried your code and echoed out the split array of url1:

Array
(
    [0] => 26
    [1] => 2496
    [2] => 1452986741
1047
    [3] => 99
    [4] => 67289856
832
    [5] => 99
    [6] => 59403539
4439
    [7] => 99
    [8] => 43517481
789
    [9] => 99
    [10] => 66642357
1212
    [11] => 99
    [12] => 37853433
1034
    [13] => 99
    [14] => 14790273
84
    [15] => 99
    [16] => 67499520
5
    [17] => 99
    [18] => 200000000
3216
    [19] => 99
    [20] => 25391207
74
    [21] => 99
    [22] => 150021891
1644
    [23] => 99
    [24] => 29627289
46
    [25] => 99
    [26] => 118777158
133
    [27] => 99
    [28] => 33158882
533
    [29] => 99
    [30] => 20629594
2962
    [31] => 99
    [32] => 17689939
42
    [33] => 99
    [34] => 62791665
2357
    [35] => 99
    [36] => 14780316
5
    [37] => 99
    [38] => 200000000
2991
    [39] => 99
    [40] => 19305640
507
    [41] => 99
    [42] => 29647401
3626
    [43] => 99
    [44] => 16798671
15711
    [45] => 99
    [46] => 13767830
1036
    [47] => 99
    [48] => 17163832
5880
    [b][49] => 99[/b]
    [50] => 13910370
590
    [51] => 120
    [52] => 112528597
2846
    [53] => 1944
-1
    [54] => -1
-1
    [55] => -1
-1
    [56] => -1
-1
    [57] => -1
4356
    [58] => 3988
3743
    [59] => 3987
2538
    [60] => 4148
5571
    [61] => 4105
-1
    [62] => -1
-1
    [63] => -1

)

Basically [49] contains "99", not 89. Why do you need to float the numbers? They're all integers...
[/quote]
Sorry about that, the link givin is to the wrong database. I updated my actual php without updating this one the real link is [url=http://hiscore.runescape.com/index_lite.ws?player=69b]http://hiscore.runescape.com/index_lite.ws?player=69b[/url] which would still imply that 51 is the correct interger. let me make a few modifications to my php, and update the image.
Edit: i tried with 51 and didnt float the numbers, and nothing.
[/quote]
[/quote]

as you quote both of us, good one

Link to comment
Share on other sites

Just to make a point, maybe it will stick :)

 

w00t another full quote!

 

This just made me cry a little, first he posts an absurdly long post, without code tags to break it down and make it formatted a bit better and then you quote it.

 

*premiso is ashamed and crawls into a hole to try and easy the shame.

 

[quote author=F0XTR0T link=topic=338672.msg1596039#msg1596039 date=1310649137]
[quote author=silkfire link=topic=338672.msg1596037#msg1596037 date=1310648948]
I tried your code and echoed out the split array of url1:

Array
(
    [0] => 26
    [1] => 2496
    [2] => 1452986741
1047
    [3] => 99
    [4] => 67289856
832
    [5] => 99
    [6] => 59403539
4439
    [7] => 99
    [8] => 43517481
789
    [9] => 99
    [10] => 66642357
1212
    [11] => 99
    [12] => 37853433
1034
    [13] => 99
    [14] => 14790273
84
    [15] => 99
    [16] => 67499520
5
    [17] => 99
    [18] => 200000000
3216
    [19] => 99
    [20] => 25391207
74
    [21] => 99
    [22] => 150021891
1644
    [23] => 99
    [24] => 29627289
46
    [25] => 99
    [26] => 118777158
133
    [27] => 99
    [28] => 33158882
533
    [29] => 99
    [30] => 20629594
2962
    [31] => 99
    [32] => 17689939
42
    [33] => 99
    [34] => 62791665
2357
    [35] => 99
    [36] => 14780316
5
    [37] => 99
    [38] => 200000000
2991
    [39] => 99
    [40] => 19305640
507
    [41] => 99
    [42] => 29647401
3626
    [43] => 99
    [44] => 16798671
15711
    [45] => 99
    [46] => 13767830
1036
    [47] => 99
    [48] => 17163832
5880
    [b][49] => 99[/b]
    [50] => 13910370
590
    [51] => 120
    [52] => 112528597
2846
    [53] => 1944
-1
    [54] => -1
-1
    [55] => -1
-1
    [56] => -1
-1
    [57] => -1
4356
    [58] => 3988
3743
    [59] => 3987
2538
    [60] => 4148
5571
    [61] => 4105
-1
    [62] => -1
-1
    [63] => -1

)

Basically [49] contains "99", not 89. Why do you need to float the numbers? They're all integers...
[/quote]
Sorry about that, the link givin is to the wrong database. I updated my actual php without updating this one the real link is [url=http://hiscore.runescape.com/index_lite.ws?player=69b]http://hiscore.runescape.com/index_lite.ws?player=69b[/url] which would still imply that 51 is the correct interger. let me make a few modifications to my php, and update the image.
Edit: i tried with 51 and didnt float the numbers, and nothing.
[/quote]
[/quote]

as you quote both of us, good one

 

hey hey dont go there. i used quote tags this time. but anyways, got a solution to my problem?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.