[2.0.16] Embed SigmaChat Chat Module into phpBB

The cleanup is complete. This forum is now read only.

Rating:

Excellent!
36
75%
Very Good
4
8%
Good
2
4%
Fair
2
4%
Poor
4
8%
 
Total votes: 48

ravencr
Registered User
Posts: 58
Joined: Fri Nov 03, 2006 5:45 pm

Post by ravencr » Fri Dec 29, 2006 4:43 am

What is wrong with this:


<?php
/******
* Get List of Chatters Online
*/
$users_url = "http://client4.addonchat.com/scwho.pl?i ... rs+in+chat.";

$html_file = file($users_url);
$html_lines = implode("\n", $html_file);

/******
* Do your choice of formatting here I just wanted a comma-seperated list
*/
$html_lines = str_replace( "<br>", ", ", $html_lines);

/******
* Strips all html tags and excess white space
*/
$html_lines = strip_tags ($html_lines);
$html_lines = trim($html_lines);

/******
* Strips last comma, only if somebody's in
*/
if (strpos($html_lines, ","))
$html_lines = "Now in chat: " . substr_replace($html_lines, "", strrpos($html_lines, ","), 1);

/******
* This is the page loaded by the iframe, here you can use a template to follow different skins
* instead of producing HTML code by php.
*/
echo "<html>
<head>
<style type=\"text/css\">

body {
margin: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}

</style>
<script type=\"text/javascript\">
var sTargetURL = \"?id=173926&countonly=0&nousermsg=There+are+currently+no+users+in+chat.\";
setTimeout(\"window.location.href = sTargetURL\", 15*1000); <!-- Here reload happens every 15 seconds, do as you like it best -->
</script>
</head>
<body>
" . $html_lines . "
</body>
</html>";
?>

ravencr
Registered User
Posts: 58
Joined: Fri Nov 03, 2006 5:45 pm

Post by ravencr » Fri Dec 29, 2006 4:44 am

Duplicate post, sorry
Last edited by ravencr on Fri Dec 29, 2006 5:10 am, edited 1 time in total.

ravencr
Registered User
Posts: 58
Joined: Fri Nov 03, 2006 5:45 pm

Post by ravencr » Fri Dec 29, 2006 4:45 am

Duplicate post, sorry

HOT SPOT
Registered User
Posts: 29
Joined: Fri Dec 22, 2006 4:23 pm

Post by HOT SPOT » Fri Dec 29, 2006 1:10 pm

disregard post.
Last edited by HOT SPOT on Fri Dec 29, 2006 1:15 pm, edited 1 time in total.

HOT SPOT
Registered User
Posts: 29
Joined: Fri Dec 22, 2006 4:23 pm

Post by HOT SPOT » Fri Dec 29, 2006 1:14 pm

ravencr,

Never mind, we were posting at the same time, your code looks good.

Seems like your server has open url blocked, not sure how to get around that.

Code: Select all

Warning: file() [function.file]: URL file-access is disabled in the server configuration in /home/.orpheus/ravencpr/utvrally.com/sigmachatcron.php on line 7

zenkinz
Registered User
Posts: 84
Joined: Mon Dec 30, 2002 2:18 pm

Post by zenkinz » Fri Dec 29, 2006 2:35 pm

HOT SPOT wrote: ravencr,

Never mind, we were posting at the same time, your code looks good.

Seems like your server has open url blocked, not sure how to get around that.

Code: Select all

Warning: file() [function.file]: URL file-access is disabled in the server configuration in /home/.orpheus/ravencpr/utvrally.com/sigmachatcron.php on line 7


you need to see if your host allows you to override php.ini configuration.

I created a mx_module to track chatter online.. see this

Image

ravencr
Registered User
Posts: 58
Joined: Fri Nov 03, 2006 5:45 pm

Post by ravencr » Fri Dec 29, 2006 3:06 pm

Here's what my host said I needed to do instead, but I'm so new to all this, I don't know if I can figure it out in comparison to the original code I copied on here:

In a measure to improve security, DreamHost has disabled the PHP option allow_url_fopen. This would normally allow a programmer to open, include or otherwise use a remote file using a URL, rather than a local file path. The cURL library provides a feature-rich alternative.

Table of contents [showhide]
1 Description

2 Examples

2.1 Fetching a web page
2.2 Alternative for file_get_contents()
2.3 Alternative for file()
2.4 Wrapping it all in an easy class


3 See Also

4 External Links

[edit]Description
cURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP. cURL supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and other useful tricks.

[edit]Examples
[edit]Fetching a web page
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>
[edit]Alternative for file_get_contents()
Instead of:

<?php
$file_contents = file_get_contents('http://example.com/');

// display file
echo $file_contents;
?>
Use this:

<?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://example.com');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);

// display file
echo $file_contents;
?>
[edit]Alternative for file()
Instead of:

<?php
$lines = file('http://example.com/');

// display file line by line
foreach($lines as $line_num => $line) {
echo "Line # {$line_num} : ".htmlspecialchars($line)."<br />\n";
}
?>
Use this:

<?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://example.com');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$lines = array();
$lines = explode("\n", $file_contents);

// display file line by line
foreach($lines as $line_num => $line) {
echo "Line # {$line_num} : ".htmlspecialchars($line)."<br />\n";
}
?>
[edit]Wrapping it all in an easy class
Use the following class to make reading/saving remote files easy. This class will automatically delete the temp files downloaded at the end of your PHP script.

<?php

class downloader {
var $tempFolder;
var $tempFiles = array();

function __destruct () {
foreach ($this->tempFiles as $file) {
unlink($file['temp']);
}
}

function __construct ($temp)
{
$this->tempFolder = $temp;
}

function get ($url) {
array_unshift($this->tempFiles, array(
'extension'=> array_pop(explode('.', $url)),
'original'=> basename($url),
'temp'=> $this->tempFolder . md5(microtime()),
));
$ch = curl_init($url);
$fp = fopen($this->tempFiles[0]['temp'], 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close($ch);
fclose($fp);
return $this->tempFiles[0]['temp'];
}

function read ($index = 0) {
return file_get_contents($this->tempFiles[$index]['temp']);
}

function readArray ($index = 0)
{
return file($this->tempFiles[$index]['temp']);
}

function listFiles () {
return $this->tempFiles;
}

function save ($path, $index = 0) {
copy($this->tempFiles[$index]['temp'], (is_dir($path) ? $path . $this->tempFiles[$index]['original'] : $path));
}
}

$d = new downloader('/home/<username>/<temp folder>');

?>

zenkinz
Registered User
Posts: 84
Joined: Mon Dec 30, 2002 2:18 pm

Post by zenkinz » Fri Dec 29, 2006 5:04 pm

ravencr wrote: Here's what my host said I needed to do instead, but I'm so new to all this, I don't know if I can figure it out in comparison to the original code I copied on here:

In a measure to improve security, DreamHost has disabled the PHP option allow_url_fopen. This would normally allow a programmer to open, include or otherwise use a remote file using a URL, rather than a local file path. The cURL library provides a feature-rich alternative.


check your account's root directory has a file call php.ini, if not, create one, add this line in the php.ini

allow_url_fopen = on


and saved it. See if it works. If it doesn't, it means that your host doesn't allow local override of php configuration, and you probably has to use cURL lib.

ravencr
Registered User
Posts: 58
Joined: Fri Nov 03, 2006 5:45 pm

Post by ravencr » Fri Dec 29, 2006 6:27 pm

I created the file named: php.ini in my root directory, added the code you have there, and it still doesn't work. There wasn't a php.ini in my root directory to begin with. Is there any other code I need in my php.ini file to make it work?

Chris

zenkinz
Registered User
Posts: 84
Joined: Mon Dec 30, 2002 2:18 pm

Post by zenkinz » Sat Dec 30, 2006 7:23 pm

ravencr wrote: I created the file named: php.ini in my root directory, added the code you have there, and it still doesn't work. There wasn't a php.ini in my root directory to begin with. Is there any other code I need in my php.ini file to make it work?

Chris


your best bet is check with your host provider to see if local config for php is allowed, and if so, where's the ini file supposed to be placed.

ravencr
Registered User
Posts: 58
Joined: Fri Nov 03, 2006 5:45 pm

Post by ravencr » Sat Dec 30, 2006 7:27 pm

I think that's why they said curl was the way to go, don't you?

Chris

User avatar
Darth Medicus
Registered User
Posts: 4
Joined: Sat Dec 09, 2006 10:26 pm
Location: United States
Contact:

Post by Darth Medicus » Mon Jan 08, 2007 3:28 pm

Disregard...I didn't notice that tiny little option at the top of the page that said chat, lol ^_^ Great mod ^_^
Darth Medicus

ravencr
Registered User
Posts: 58
Joined: Fri Nov 03, 2006 5:45 pm

Post by ravencr » Sat Jan 13, 2007 9:07 am

Has anyone noticed their chat being down today?

Chris

superbuddy
Registered User
Posts: 14
Joined: Wed Jan 17, 2007 7:17 pm

It Wont Work :(

Post by superbuddy » Wed Jan 17, 2007 7:20 pm

Hey guys, i have done everything that i need to, and its not working, is it down or something?

the page comes up and everyhting but no chat room opens :(

take a look

www.halesentertainment.co.uk/forum

Please if anyone can help, let me know

Cheers

superbuddy
Registered User
Posts: 14
Joined: Wed Jan 17, 2007 7:17 pm

all sorted now

Post by superbuddy » Fri Jan 19, 2007 8:52 pm

Hey guys, it seems to be working now


Is there anyway you can show how many people are in the chat room?

like:

Chat (7)

so the number next to the chat button, will represent how many people ae in the chat room

this would be very very handy to have :)

Cheers in advance

Post Reply

Return to “[2.0.x] MOD Database Cleanup”

Who is online

Users browsing this forum: No registered users and 12 guests