Pro.Luv
Members-
Posts
33 -
Joined
-
Last visited
Never
Everything posted by Pro.Luv
-
Hi, I'm trying to call a .net(.asmx) webservice and it just doesn't work, I really need help with this. require("nusoap.php"); $client = new nusoap_client('http://www.w3schools.com/webservices/tempconvert.asmx?wsdl', true); $err = $client->getError(); if($err){ Print '<h2>Constructor error</h2><pre>'.$err.'</pre>'; } $param = array('Celsius' => '12') ; //PARAMETERS $function = 'CelsiusToFahrenheit'; //FUNCTION IM CALLING $result = $client->call($function, $param); if ($client->fault) { Print '<h2>Fault</h2><pre>'; print_r($result); Print '</pre>'; } else { $err = $client->getError(); // Check for errors if ($err) { Print '<h2>Error</h2><pre>'.$err.'</pre>'; // Display the error } else { // Display the result Print '<h2>Result</h2><pre>'; print_r($result); Print '</pre>'; } } Thanks !
-
Hi, I'm having a problem using ftp_rawlist when I chmod a file the permissions are updated but it doesn't show when I list the files it shows the file's old permissions, but when I view the file permissions using FileZilla it shows that the file has been updated. Example: Before ftp_chmod file.php -rw-r--r-- After I chmod the file using the code below it still shows the -rw-r--r-- permissions it doesn't update but using filezilla shows that it's permissions have been updated. This is the FTP_chmod code that I use: $conn_id = ftp_connect($host); $login_result = ftp_login($conn_id, $user, $pass); $file = $_GET["file"]; if (ftp_chmod($conn_id, 0644, $file) !== false) { Print "$file chmoded successfully to 0644\n"; } else { Print "could not chmod $file\n"; } This is the function that I use to list the files on a server: function raw_listing($conn, $path){ $list = ftp_rawlist($conn, "./"); //GET RAW DIRECTORY LIST $i = 0; foreach ($list as $current) { $split = preg_split("[ ]", $current, 9, PREG_SPLIT_NO_EMPTY); if ($split[0] != "total") { $parsed[$i]['isdir'] = $split[0]{0} === "d"; $parsed[$i]['perms'] = $split[0]; $parsed[$i]['number'] = $split[1]; $parsed[$i]['owner'] = $split[2]; $parsed[$i]['group'] = $split[3]; $parsed[$i]['size'] = $split[4]; $parsed[$i]['month'] = $split[5]; $parsed[$i]['day'] = $split[6]; $parsed[$i]['time/year'] = $split[7]; $parsed[$i]['name'] = $split[8]; $i++; } } return $parsed; } The listing of the files seem fine but it's only the permissions that show wrong. Thanks
-
Hi, I need help with this code it does work I need to know how I can send back data from the server.php to the client.php.. Client.php /* Open a socket to port 1234 on localhost */ $socket = stream_socket_client('tcp://127.0.0.1:1234'); /* Send more data out of band. */ stream_socket_sendto($socket, "This Data", STREAM_OOB); /* Close it up */ fclose($socket); Server.php // Open a server socket to port 1234 on localhost $server = stream_socket_server('tcp://127.0.0.1:1234'); // Accept a connection $socket = stream_socket_accept($server); echo "Waiting for data from client..."; // Output recieved data $data = stream_socket_recvfrom($socket, 1500); echo "Data: ".$data."\n"; //do something here then send results back. // Close it up fclose($socket); fclose($server); The client sends This Data to the server and the server retrieves it... I need to know what must I add to the server.php to send back data ? In server.php: I want to take the data being sent from the client.php and search it in the database then send back results to the client for displaying. Thanks
-
Thanks alot for the reply, the client.php is right ? is there anything I need to add in there so that I can send data to the server.php ? Really appreciate your help. My server.php now is: $socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); socket_bind($socket,'127.0.0.1', $port); socket_listen($socket); while(true) { if(is_resource($newSocket = socket_accept($socket))) { // do something with $newSocket echo $newSocket; socket_close($newSocket); } } socket_close($socket);
-
Hi, I read online documentation but I stil can't get this right I need to create a PHP page that will send data to another PHP page using sockets so far I got this: client.php function ping($host) { $package = "\x08\x00\x19\x2f\x00\x00\x00\x00\x70\x69\x6e\x67"; /* create the socket, the last '1' denotes ICMP */ $socket = socket_create(AF_INET, SOCK_RAW, 1); /* set socket receive timeout to 1 second */ socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 1, "usec" => 0)); /* connect to socket */ socket_connect($socket, $host, null); /* record start time */ list($start_usec, $start_sec) = explode(" ", microtime()); $start_time = ((float) $start_usec + (float) $start_sec); socket_send($socket, $package, strlen($package), 0); if(@socket_read($socket, 255)) { list($end_usec, $end_sec) = explode(" ", microtime()); $end_time = ((float) $end_usec + (float) $end_sec); $total_time = $end_time - $start_time; $great = "Working !!"; return $total_time." - ".$great; } else { return false; } socket_close($socket); } ping("127.0.0.1"); when I use the function it passes back to the same page I need it to send to this page server.php error_reporting(E_ALL | E_STRICT); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_bind($socket, '127.0.0.1', 1223); $from = "127.0.0.1"; $port = 80; socket_recvfrom($socket, $buf, 12, 0, $from, $port); echo "Received $buf from remote address $from and remote port $port" . PHP_EOL; I really need help with this. Thanks
-
Hi, I have this code that works fine, the problem is the code only works if Im adding numbers $sum = "1 + 1 + 1"; function str2num($Str) { $numTotal = 0; if ( $Nums = explode('+', $Str) ) { foreach ( $Nums as $Num ) $numTotal += $Num; return $numTotal; } else return 0; } print(str2num($sum)); I need this to work for any type of sum like: $sum = "1 + 1 + 5 - 2 * 2"; please help Thanks !
-
Hi, Im still getting used to regex and I need some help could someone show me how to match javascript like : <script type="text/javascript"> function one(){ code.... } </script> how can I match this in html code ? I'm reading a file into a string I want to then find if theres javascript in the code and remove it ? Im using this to read the file: $html = file_get_contents("test.html"); Please help !
-
Hi, Im using this code to read a robot.txt file then add all the disallowed file and directories to an array $filename = "robots.txt"; $disallows = array(); $handle = fopen($filename, "rb"); $contents = fread($handle, filesize($filename)); preg_match_all("/Disallow:\s*(.+)/im", $contents, $foo); $disallow = $foo[1]; while(list($key, $value) = each($disallow)){ print $value. "<br />"; } fclose($handle); Now what i want to do is pass a link then check if the link or part of the link is in the array like: if(in_array("http://www.site.com/disallowedDir/", $disallow)){ //Skip link }else{ //do something cause link is not in array } I need to know how to do this thanks
-
Hi, I know how to use this to get meta tags the problem is sometimes it takes long to fetch meta tags and then I get a message saying: Maximum execution time of 60 seconds exceeded.. my code... $metatags = @ get_meta_tags($url); $title = $metatags["title"]; $description = $metatags["description"]; $keywords = $metatags["keywords"]; Thanks
-
Hi, I'm running a query from the my database, each time the query loops it fetch's an address then goes to that address and gets all the links from that address.. problem is after a few addresses it stops is this a database problem ? do I have to give the query a break inbetween ? I need this query to be running at all times Thanks
-
hi ngreenwood6, it is counting if you check: if ($_GET["pgnum"] == $cpgnum){ print "<a href=\"$PHP_SELF?offset=$newoffset&pgnum=$cpgnum&pages=$pages\" $active $active1><b>$cpgnum</b></a> | "; } else { print "<a href=\"$PHP_SELF?offset=$newoffset&pgnum=$cpgnum&pages=$pages\" $active $active1>$cpgnum</a> | "; } } //COUNTING HERE $count++;
-
Hi, I have this code that I need help with its something like a pagination: <? $pages = 20; $limit = 10; $count = 0; if (strlen($_GET["pgnum"]) == 0 OR $_GET["pgnum"] == 1){$disablePrevious = "disabled"; } else { $disablePrevious = ""; } $nextpagePrevious = $_GET["pgnum"] - 1; print "<a href=\"$PHP_SELF?offset=$limit&pgnum=$nextpagePrevious&pages=$pages\" style=\"text-decoration:none\" <input type=\"button\" value=\"< Previous\" $disablePrevious></a> "; for ($i=1;$i<=$pages;$i++) { $newoffset=$limit*($i-1); $cpgnum = $i; if ($pages > 1) { //REMOVE TO PRINT 20 links if ($count == $limit){ print "... "; break; } if ($_GET["pgnum"] == $cpgnum){ print "<a href=\"$PHP_SELF?offset=$newoffset&pgnum=$cpgnum&pages=$pages\"><b>$cpgnum</b></a> | "; } else { print "<a href=\"$PHP_SELF?offset=$newoffset&pgnum=$cpgnum&pages=$pages\">$cpgnum</a> | "; } } $count++; } if ($_GET["pgnum"] AND $_GET["pgnum"] == $_GET["pages"]){$disableNext = "disabled";} else{$disableNext = "";} $nextpage = $_GET["pgnum"] + 1; print "<a href=\"$PHP_SELF?offset=$limit&pgnum=$nextpage&pages=$pages\" style=\"text-decoration:none\"><input type=\"button\" value=\"Next >\" $disableNext></a>"; ?> what this code basically does is print out 10 links this code: if ($count == $limit){ print "... "; break; } checks if $count is equal to limit and at the top you see $limit is set to 10.. so it only prints out 10 links if you remove the code above it will print 20 links.. I want to only show 10 links then when the 10th link is shown I want show the 11th link then 12th like before 10th link is reached: 1,2,3,4,5,6,7,8,9,10 after 10th link is reached 2,3,4,5,6,7,8,9,10,11 and so on.. The 1 goes away and the 11th link shows. Really need help with this! thanks
-
thanks premiso will read up on it, thanks for all the help!!
-
I'm sorry if I'm confusing you ted_chou12 really am great full for your help.. I'm trying to Define a named constant..
-
It's PHP... When you use define and you want to change a word say for example: welcome.. it would be define("welcome","Welcome User !"); echo welcome; // gives you Welcome User ! echo "welcome"; //gives you welcome, no change
-
I tried using: echo "and"; echo "if"; but when the in inverted comma's the word does not change to the language selected. I checked the manual: define("CONSTANT", "Hello world."); echo CONSTANT; // outputs "Hello world." echo Constant; // outputs "Constant" and issues a notice. it shows that echo is used without the inverted comma's
-
Hi guys, I'm using define to change the page language like: define('home','Heim',true); the problem I'm having is if I echo strings with inverted comma's they don't change like: echo "Home"; The home doesn't change unless I echo it without the inverted comma's echo home; This is making it difficult cause I can't print out reserved words like " and, if " like: echo and; echo if; I get error's how can I echo those words ? I really need help with this and I have chinese as a language but when I create the php document like: define("search", "搜索",true); the chinese words turn into ?? question marks is it my editor ? I really need help with this... Thanks
-
Hi, I have this code that gets links from web pages but it also gets javascript links like if a link is: document.form1.brand.options[document.form1.brand.selectedIndex].value I don't want it to fetch those links how can I stop it ? <? function getLinks($link) { /*** return array ***/ $ret = array(); /*** a new dom object ***/ $dom = new domDocument; /*** get the HTML (suppress errors) ***/ @$dom->loadHTML(file_get_contents($link)); /*** remove silly white space ***/ $dom->preserveWhiteSpace = false; /*** get the links from the HTML ***/ $links = $dom->getElementsByTagName('a'); /*** loop over the links ***/ foreach ($links as $tag) { $ret[$tag->getAttribute('href')] = $tag->childNodes->item(0)->nodeValue; } return $ret; } /*** a link to search ***/ $link = "http://www.website.com"; /*** get the links ***/ $urls = getLinks($link); /*** check for results ***/ if(sizeof($urls) > 0) { foreach($urls as $key => $value) { echo $key.'<br >'; } } else { echo "No links found at $link"; } ?> thanks
-
Hey, I want to take a URL for example: http://www.website.com/ I want to replace the last "/" so that it's like.. http://www.website.com But I need to first check if the last "/" exists because not all the URL's I'm parsing has the slash. I'm not really any good with Regex I appreciate any help Thanks
-
Okay.. I have something like this: eg. $value = <a href="http://www.website.com/link.htm">Link 1</a> if (ereg ("(^http|^https)", $value, $regs)){ print($value."<br />"); } This just match's if the link start's with HTTP or HTTPS, if it does then print it out, I sometimes come across links that are like: <a href="page.htm"> Page </a> AND <a href="/page1.htm"> Page </a> So I want to also print out those links but I need to get the full address I would then change this.. if (ereg ("(^http|^https|^/|^)", $value, $regs)){ print($value."<br />"); } Correct me if I'm mistaken
-
Hi premiso, It's on someone elses... Could you show me code when you say... I would really appreciate it
-
Hi, I need to get the full address of links if a link is: <a href="page.htm"> Page </a> How can I get the full address of that link so that it looks like: http://www.website.com/page.htm And if a link is like: <a href="/page1.htm"> Page </a> how can I get the address like http://www.website.com/page1.htm Really need help with this thanks!
-
Hi, Can anyone tell me how to get the time of how long it takes to run a query like if I had to run a query like: SELECT * FROM table I need to find out how long it takes to get the data in seconds. Thanks
-
Hi gevans, no not that type of absolute...
-
I revraz, I'm sorry about that I got it mixed up, I want to make those links absolute from relative. Thanks