[03-Dec-2017 12:54:39 UTC] PHP Notice: Trying to get property of non-object in
#1
[03-Dec-2017 12:54:39 UTC] PHP Notice:  Trying to get property of non-object in /home/proximity/public_html/proximity.gq/postcount.php on line 77
[03-Dec-2017 12:54:39 UTC] PHP Notice:  Trying to get property of non-object in /home/proximity/public_html/proximity.gq/postcount.php on line 84


I don't know why i'm getting this problem.
Can someone help me resolve this?

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
include 'simple_html_dom.php';

$nopointsforums = array(
        'SPAM/Testing' => true,
        'Introductions' => true,
);
/**
 * Writes the given text with a border into the image using TrueType fonts.
 * @author John Ciacia
 * @param image An image resource
 * @param size The font size
 * @param angle The angle in degrees to rotate the text
 * @param x Upper left corner of the text
 * @param y Lower left corner of the text
 * @param textcolor This is the color of the main text
 * @param strokecolor This is the color of the text border
 * @param fontfile The path to the TrueType font you wish to use
 * @param text The text string in UTF-8 encoding
 * @param px Number of pixels the text border will be
 * @see http://us.php.net/manual/en/function.imagettftext.php
 */
function imagettfstroketext(&$image, $size, $angle, $x, $y, &$textcolor, &$strokecolor, $fontfile, $text, $px) {

    for($c1 = ($x-abs($px)); $c1 <= ($x+abs($px)); $c1++)
        for($c2 = ($y-abs($px)); $c2 <= ($y+abs($px)); $c2++)
            $bg = imagettftext($image, $size, $angle, $c1, $c2, $strokecolor, $fontfile, $text);

   return imagettftext($image, $size, $angle, $x, $y, $textcolor, $fontfile, $text);
}
//end

$userpage = file_get_html('http://forum.proximity.host/user-'.$_GET["userid"].'.html');
$username = $userpage->find('span[class="largetext"]', 0)->plaintext; // find the username from the user profile page.
//refer to http://simplehtmldom.sourceforge.net/manual.htm

$url="http://forum.proximity.host/search.php?action=finduser&uid=".$_GET["userid"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Must be set to true so that PHP follows any "Location:" header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$a = curl_exec($ch); // $a will contain all headers

$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); // This is what you need, it will return you the last effective URL

// Uncomment to see all headers
/*
echo "<pre>";
print_r($a);echo"<br>";
echo "</pre>";
*/

//echo $url; // Voila
/* the above code was taken from http://stackoverflow.com/questions/20233115/how-to-get-destination-url-from-redirection-url-in-php
when clicking on "Find more posts" it appears the resulting search page that only returns the user's posts is dynamically generated*/

$numberofpoststhismonth = 0;
$uncountedposts = 0;
$numberofpostsnotmadeinthismonth = 0;
$pagenumber = 1;
$firstrun = True;
while (($numberofpostsnotmadeinthismonth === 0 and $numberofpoststhismonth != 0) or $firstrun === True) {
        if ($pagenumber === 1) {
                $firstrun = False;
        }
        $html = file_get_html($url.'&sortby=dateline&order=desc&uid=&page='.$pagenumber);
        $rows = 0;
        foreach($html->find('table[class="tborder"] tr') as $element)
        {

		// Ignore first two rows.
                if ($rows++ < 2)
                    continue;
                $post = $element->find('*[style="white-space: nowrap; text-align: center;"]',0);
                $forum = $element->find('a', 3)->innertext;
				
		// Forum doesn't give points.
				if (isset($nopointsforums[$forum])) {
                                        $uncountedposts++;
					continue;
				}
				if (!is_string($post->plaintext)) {
					continue;
				}
                
				if (substr($post->plaintext, 0, 3) === 'Yes' or substr($post->plaintext, 0, 3) === 'Tod' or substr($post->plaintext, 0, 3) === date("m-")) {
					$numberofpoststhismonth++;

/* http://transfusion.cf/tf-content/uploads/2013/12/screenshot_134.png We are crawling the webpage for the timestamps of the posts - if they begin with YESterday or TODay or the current month.- 
If all the posts on the first search page are made this month, $pagenumber++ */
         }
				else {
					$numberofpostsnotmadeinthismonth++;
				}
	}
	$totalposts = $uncountedposts+$numberofpoststhismonth;
	if (($totalposts %= 20) != 0) {
                $numberofpostsnotmadeinthismonth++;
        }
        $pagenumber++;
}

header('Pragma: public');
header('Cache-Control: max-age=240');
header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 240));
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])){ 
  // if the browser has a cached version of this image, send 304 
  header('Last-Modified: '.$_SERVER['HTTP_IF_MODIFIED_SINCE'],true,304); 
  exit; 
} 
// Force the browser to cache the image for 4 minutes. Crawling webpages like that is not exactly good etiquette.

header("Content-Type: image/png");
$img = imagecreatefrompng("./freevpsbg.png"); // the background image.
$font_color = imagecolorallocate($img, 255, 255, 255);
$stroke_color = imagecolorallocate($img, 0, 0, 0);
$posts_color = imagecolorallocate($img, 221, 255, 0);
imagettfstroketext($img, 8, 0, 50, 13, $font_color, $stroke_color, "./visitor1.ttf", $username."'s posts: ", 1);
imagettfstroketext($img, 8, 0, 173, 13, $posts_color, $stroke_color, "./visitor1.ttf", $numberofpoststhismonth, 1);
imagettfstroketext($img, 8, 0, 183, 13, $font_color, $stroke_color, "./visitor1.ttf", "/20", 1);
if ($numberofpoststhismonth >= 40) {
        $message="posessed poster!";
        $message_color = imagecolorallocate($img, 111, 255, 0);
} elseif ($numberofpoststhismonth >= 30) {
        $message="Sociable Seal!";
        $message_color = imagecolorallocate($img, 0, 255, 222);
} elseif ($numberofpoststhismonth >= 20) {
        $message="Completed! Chewsum5gum";
        $message_color = imagecolorallocate($img, 0, 255, 0);
} elseif ($numberofpoststhismonth >= 17) {
        $message="OH! LIVIN ON A PRAYER";
        $message_color = imagecolorallocate($img, 255, 100, 0);
} elseif ($numberofpoststhismonth >=15) {
        $message="WOAH, HALFWAY THERE";
        $message_color = imagecolorallocate($img, 255, 255, 0);
} elseif ($numberofpoststhismonth >= 0) {
        $message="Dry your tears n Post";
        $message_color = imagecolorallocate($img, 255, 0, 0);
}
imagettfstroketext($img, 10, 0, 50, 26, $message_color, $stroke_color, "./visitor1.ttf", $message, 1);
// http://www.johnciacia.com/2010/01/04/using-php-and-gd-to-add-border-to-text/
imagepng($img);
imagedestroy($img);
// free memory associated with this image - delete it from the PHP cache
//echo $numberofpoststhismonth;
//echo date("m-d");
?>

       My Post Count:
[Image: img.php?userid=20087&vps2]




#2
$forum = $element->find('a', 3)->innertext;

The error leads to the fact that $element->find('a', 3) isn't an object, therefore it cannot have any properties.

Same thing on line 84. $post isn't an object either.

I suggest you check over the parts where you create the objects. At the moment, I can't debug and solve this for you, unless you're willing to wait for another 24 hours where I'll have the chance to fix it for you.

@Abdul Sami

Honestly, couldn't seem to find the underlying issue.
Since you own the forum, why don't you just find post counts using the database? It should be quicker.
I'm not going to be that person who throws up another signature which displays my posts for the month. My goal is to be active enough to reach the post requirements without staring at a counter thinking, "Great! I'm done my posts, I can log off until next month."

-- FlamesRunner

My website } { GitHub } { Contact me: andrew@andrew-hong.me }

#3
Hi!
Actually, I tried debugging at my own, First it was giving error of File_get_content, I changed php version and that seems to fixed it. But this error came, Which i cannot actually seem to fix it.

I can post user post by using MyBB Post counter but i was thinking for the user that they could get images in their signature and make easy for them. When you have free time do let me know.
       My Post Count:
[Image: img.php?userid=20087&vps2]




#4

Code:
curl -vvv http://forum.proximity.host/search.php?action=finduser&uid=1 > c
response : <p>The document has been temporarily moved.</p>

i had the same problem one time with my site while trying to use file_get_contents, nothing changed in my code just webserver, after a day i found that problem was SSL.





Users browsing this thread: 1 Guest(s)

Switch to mobile version

Sponsors: Ftpit - ZXPlay - GalaxyHostPlus - Verelox- HostUS - Host4Fun - Evolution-Host - NodeBlade - HostDare - VPSMost


BitCoin donations: 1DQxbstaTb5SWk6QC2gFeQUTFR64JX4cEo