Jump to content

Re-JeeP

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Re-JeeP's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hmm... I tought that when you for example made an API you used comments like that to describe the class. For example in java... http://java.sun.com/j2se/1.5.0/docs/api/
  2. Hi! Where can I learn to use theese kind of comments in php? /** * * * **/ // Johan
  3. Hi! Could anyone help me with a reg exp that check if a string matches a date? format: YYYY-MM-DD Thanks! // Johan
  4. Hi! I have made a class that collects the headers a server sends when you visit it threw port 80. Because I'm new to OOP I'd want some feedback on my class. [code]<?php class headers { var $server; var $port; var $fp; function headers($server, $port = 80) { $this->server = $server; $this->port = $port; } function get_headers() { $this->fp = $this->connect(); if($this->fp) { $this->send_request(); $output = $this->save(); $this->close(); return $this->trim_output($output); } else { return array("Failed!"); } } function trim_output($output) { $rows = explode("\n", $output); foreach($rows as $value) { if($value == "\r") { return $headers; } else { $headers[] = htmlentities($value); } } return $headers; } function connect() { return fsockopen($this->server, $this->port, $errno, $errstr, 5); } function send_request() { return fputs($this->fp, "GET / HTTP/1.1\r\nHost: $this->server\r\n\r\n"); } function save() { while(!feof($this->fp)) { $result .= fgets($this->fp, 128); } return $result; } function close() { return fclose($this->fp); } } $headers = new headers("domain.com"); $get = $headers->get_headers(); foreach($get as $value) { echo $value."<br />"; } ?>[/code] Thanks! // Johan
  5. [quote]AddType application/x-httpd-phps .phps[/quote] I tried to put the text into a .htaccess-file but it didn't work. Since I can't get access to httpd.conf I need some other solution!
  6. Hi! I'm using this link to view a script. <a href="script.phps" target="_blank">Script</a> But it dosen't show the page, it pops up a downloader instead. I searched some infomation about it and a header seemed to solve it. But i don't realy now how to use it! Any ideas? // Johan
  7. Thanks alot! Works now. I changed it a bit. The script now look like this: [code]<?php class mysql { function db_conn($database) { $mysql_server = "localhost"; $mysql_user = "root"; $mysql_password = ""; $mysql_database = $database; $conn = mysql_connect($mysql_server, $mysql_user, $mysql_password); mysql_select_db($mysql_database, $conn); } } class iplog { var $ip = ''; function set_ip() { $this->ip = $_SERVER['REMOTE_ADDR']; } function check() { $sql = mysql_query("SELECT ip FROM log WHERE ip = '{$this->ip}'"); if(mysql_num_rows($sql) == 0) { return true; } else { return false; } } function set() { if($this->check($this->set_ip())) { $sql = mysql_query("INSERT INTO log (ip, times) VALUES ('{$this->ip}', '1')"); } else { $sql = mysql_query("UPDATE log SET times = times + 1 WHERE ip = '{$this->ip}'"); } } } $mysql = new mysql; $mysql->db_conn("iplog"); $iplog = new iplog; $iplog->set(); ?>[/code]
  8. Hi! Thanks for answering! I know have this code. But it just gives me a blank ip in the database. [code]<?php class mysql { function db_conn($database) { $mysql_server = "localhost"; $mysql_user = "root"; $mysql_password = ""; $mysql_database = $database; $conn = mysql_connect($mysql_server, $mysql_user, $mysql_password); mysql_select_db($mysql_database, $conn); } } class iplog { var $ip = ''; function check($ip) { $sql = mysql_query("SELECT ip FROM log WHERE ip = '{$ip}'"); if(mysql_num_rows($sql) == 0) { return true; } else { return false; } } function set() { if($this->check($ip)) { $sql = mysql_query("INSERT INTO log (ip, times) VALUES ('{$ip}', '1')"); } else { $sql = mysql_query("UPDATE log SET times = times + 1 WHERE ip = '{$ip}'"); } } } $mysql = new mysql; $mysql->db_conn("iplog"); $iplog = new iplog; $iplog->set(); $iplog->ip = $_SERVER['REMOTE_ADDR']; ?>[/code]
  9. Hi! I'm having some problem with my ip-log function. Could anyone give me a good solution on how to handle the ip in the class!? Difficult to explane, hope someone get what i mean! [code]<?php class mysql { function db_conn($database) { $mysql_server = "localhost"; $mysql_user = "root"; $mysql_password = ""; $mysql_database = $database; $conn = mysql_connect($mysql_server, $mysql_user, $mysql_password); mysql_select_db($mysql_database, $conn); } } class iplog { function check() { $sql = mysql_query("SELECT ip FROM log WHERE ip = '{$this->ip}'"); if(mysql_num_rows($sql) == 0) { return true; } else { return false; } } function set($ip) { if($this->check()) { $sql = mysql_query("INSERT INTO log (ip, times) VALUES ('{$ip}', '1')"); } else { $sql = mysql_query("UPDATE log SET times = times + 1 WHERE ip = '{$ip}'"); } } } $mysql = new mysql; $mysql->db_conn("iplog"); $iplog = new iplog; $iplog->set($_SERVER['REMOTE_ADDR']); ?>[/code] // Johan
  10. Hi! Does anybody know how to stop / abort an AJAX-Request? // Johan
  11. Hi! I want to se how many mails I've got on my mail-server. I come up wih the code below but it dosen't work! [code]<?php function telnet_check_status($server, $port, $user, $pass) { $fp = fsockopen($server, $port, $errno, $errstr, 10); if(!$fp) { echo "Error: $errstr ($errno)<br />"; } else { $command = "USER ".$user."\r\n"; fwrite($fp, $command); $command = "PASS ".$pass."\r\n"; fwrite($fp, $command); $command = "QUIT\r\n"; fwrite($fp, $command); while(!feof($fp)) { $result .= fgets($fp, 128); } fclose($fp); } echo $result; } ?>[/code] I get the folowing message: [quote="message"]+OK POP3 server ready (7.1.026.6) <7BDB52E280D9D910ED3F7A00A4BFD90EE706287D@pne-msproxy2-sn2.hy.skanova.net> +OK Password required -ERR [SYS/PERM] mailbox locked by a POP3 session[/quote] Any ideas?
  12. Hi! I want to create a telnet function with fsockopen. could someone get me a hint how to do it!? Best regards! //Johan
  13. [quote author=kenrbnsn link=topic=100579.msg397143#msg397143 date=1152897627] With the time limit set to 0 (infinate) the script worked fine. Ken [/quote] Hi again! I tried the script at home but did'nt get it to work all the time. I clocked it and if it timed out it stopped at about 75 sec. Same error mess...
×
×
  • 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.