PHP - Controlling Tor Network With Php
I have a PHP app that I wrote that requires a new IP address each time that it is run. Currently I use Tor on my desktop and the Vidalia app to change the Tor identity each time I run the script but I want to automate this. Can anyone help with switching Tor identities with PHP? Essentially after my script runs I need to call a function that switches to a new Tor identity.
I have the following code but it doesn't seem to work, and I am not sure why. I am running this from XAMPP on OSX, Tor is running locally (client not server)... in my Tor settings I have 127.0.0.1 and port 9051, set to "no password"... Code: [Select] <?php function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code='') { $fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30); if (!$fp) { return false; //can't connect to the control port } fputs($fp, "AUTHENTICATE $auth_code\r\n"); $response = fread($fp, 1024); list($code, $text) = explode(' ', $response, 2); if ($code != '250') { return false; //authentication failed } //send the request to for new identity fputs($fp, "signal NEWNYM\r\n"); $response = fread($fp, 1024); list($code, $text) = explode(' ', $response, 2); if ($code != '250') { return false; //signal failed } fclose($fp); return true; } tor_new_identity(); ?> Similar TutorialsHello PHPFreaks, I'm sorry about the vague topic title, but allow me to explain: I got a PHP form with some fields, and it sends the input data to me, and a copy to the person that submits it. Only the receiver of the email sees the email it came from as: example.com@webhost-mailserver.com, rather than just "example.com" or "info@example.com". Is there a way to control this, so people dont see the root host? Coding: // send email $headers = "From: \"$naam\" <$email>\n"; $subject = "Contactformulier Kartalin"; $from = "Kartalin.nl"; $message = " blabla their input etc. "; mail ("$youremail", $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1"); If you need more of the code let me know, but as far as I can tell this seems to be the part where it can be changed (coming from a PHP-dummy ) Thanks in advance! Dave Hi. how can I control a progress meter/bar to display errors when it failed to reach 100% or on getting to a point? thanks Hey! Normally I'm very good with researching my problems, but I just can't think of what to search for, what I am wanting to do is design a script that sends a command to a batch file that is already open and running (or something to that effect), does anyone know how this would be possible, all help would be appreciated! Thank you for your time Regards GreenFanta This may sound like an odd thought, but us beginners come up with weird ideas sometimes. I'm trying to solve a "three letters or less" search. Basically if the user enters 4 words or more, my script does a fulltext search. If they do 3 letters or less, it does a basic search. But how can I write the script so that it only searches for those matching letters that have either a space in front or at the end... or that start with the three letters searched. so, if they type in "elm" I want to get "chinese elm" I want to get "Elmendorf's onion" I don't want to get "engelman's spruce"... or at the very least have results with no space on either side be at the end of the results? right now, I'm just doing a basic search and a basic search that concatenates two fields: Code: [Select] $data = mysql_query("SELECT * FROM plantae WHERE common_name_english LIKE '%$item%'"); Code: [Select] $data = mysql_query("SELECT * FROM plantae WHERE CONCAT(taxonomic_genus,' ',scientific_name) LIKE '%$item%'"); Hi, I'm a bit of a newbie when it comes to PHP. I'm a thirs year music/music tech student and for my disseration I took a very ambitious task. I want to create a sort of social networking site for musicians. But I wanted to create it dynamically using PHP and MySQL. I want to basically allow users to register and sign up with their details basically. But the first problem I came across was actually making a custom registration page, I wanted things such as post codes (zip codes) so that I would then have a Google Maps overlay showing where users were. So that you could 'see' you local music 'scene'. So far I've been playing around with Joomla, Drupal and WordPress. I tried writing the PHP from scratch but after following various tutorials, but I had no luck what-so-ever with that approach. So I started using content management systems, which got me a lot closer, but I found I couldn't really edit custom registration pages etc. And the I would have no idea how to get the Google maps idea working. If anyone could nudge me in the right direction and give me a few tips and ideas as to how I'm most likely to achieve this then please reply, I would be highly grateful for you responses. Thanks, Ewan Valentine. Hi all, I am trying to create a socket that can read from and write to a client. This is my first attempt at it and the code in question is based more or less on a python script a friend sent me as well as some php tutorials google supplied. The problem is (and this seems to be a reoccurring one) when I run it from the command line Code: [Select] php -q server.php nothing visibly happens. Can anyone see what the problem might be? Code: [Select] <?php $host = "localhost"; $port = 50007; set_time_limit(0); // no timeout $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // create $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // bind $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // listen echo "Waiting for connections...\n"; $contact = socket_accept($socket) or die("Could not accept incoming connection\n"); // accept $input = socket_read($contact, 1024) or die("Could not read input\n"); // read $input = trim($input); // clean $output = "Greetings, you have connected to a socket.\n"; socket_write($contact, $output, strlen ($output)) or die("Could not write output\n"); // return socket_close($contact); // close socket socket_close($socket); // close socket ?> This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=327407.0 Hi,
I'm not sure if this is possible, however I'm sure somebody will be able to point me in the right direction. Relativley new to php here.
I would like to write a small app that will change my IP/Subnet Mask/Gateway depending on a selection made from a dropdown list. I will have a tota; of 50 different IP settings & drop downs (each drop down will represent a different location)
I have yet to start writing the app, just on paper so far - can this be done?
I have seen examples of batch scripts like the one below that work, would I need to incorporate something like this into my php?
netsh int ipv4 set address name="Local Area Connection" source=static address=10.127.86.25 mask=255.255.255.240 gateway=10.127.86.30This is just a personal project, I'm trying to further my knowledge! Thanks J
Hello all, <?php // Connect to Phpmyadmin database localhost. $hostname = "localhost";//"";127.0.0.1 $username = "root"; $password = "password";//"password"; $dbname = "test"; $conn = new mysqli($hostname, $username, $password, $dbname); if($conn -> connect_error) { die("Connection failed: " . $conn -> connect_error); } // USED to CHANGE the db. - (mysqli_select_db($con, "test") or die()); /* Check to make all fields entered -make sure submitted- #2*/ if(isset($_POST["register"])) { if(!$_POST["email"] | !$_POST["password"] | !$_POST["password2"]) { die("You did not fill in all the fields"); } /* do escape strings for SQL injection */ $emailsafe = mysqli_real_escape_string($conn, $_POST["email"]); $passsafe = mysqli_real_escape_string($conn, $_POST["password"]); $pass2safe = mysqli_real_escape_string($conn, $_POST["password2"]); /* Check and see if email EXISTS in db. */ /* Insert email in db if does not exist */ $sql = "SELECT email FROM users WHERE email = '$emailsafe'";//limit 1 $result = $conn->query($sql) or die("invalid email check " . mysqli_error($conn)); $numrows = mysqli_num_rows($result); if($numrows != 0) { die("Sorry the email " . $_POST["email"] . "is already in use"); } // check if passwords both match if($_POST["password"] != $_POST["password2"]) { die("Passwords did NOT match"); } // if passwords match encrypt $hashedpass = password_hash($passsafe, PASSWORD_DEFAULT); // With everything escaped and hashed INSERT into db. $sqlINSERT = "INSERT INTO users(email, password) " . "VALUES('" . $emailsafe ."','". $hashedpass ."')"; if($query = $conn->query($sqlINSERT)=== TRUE) { echo '<script type="text/javascript">alert("Successfully INSERTed");</script>'; } else { die("Unsuccessful"); } $conn->close(); ?>
I ran my php with ajax and it creates the file successfully so i know it runs. I wanted to setup PHP debugging with atom or visual studio but i have not been able to successfully do that... I tried with xdebug so i just use the network tab inchrome to find if errors exist. Is there a way to write a file to a directory on my network? I tried creating a shortcut called automated and pointed it to the network path. I also set up a virtual directory called automated in IIS and still could not make it work. I gave it read and write permissions. error Warning: fopen(C:\Inetpub\wwwroot\dompdf\automated\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69 Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 70 Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 71 code Code: [Select] require_once("dompdf/dompdf_config.inc.php"); $html = '<html><body>'. '<p>Put your html here, or generate it with your favourite '. 'templating system.</p>'. '</body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $pdfoutput = $dompdf->output(); $filename = "C:\\Inetpub\\wwwroot\\dompdf\\automated\\resource.pdf"; $fp = fopen($filename, "a"); fwrite($fp, $pdfoutput); fclose($fp); I'm writing a mini social network and I'm having trouble figuring out how to deal with privacy settings. I have established a range of privacy options (level 1-4): 1. Only Facebook friends can see profile (users connect via FB) 2. Only current classmates 3. Past + current classmates 4. All users in given group I am writing a function to return a list of available users based on a given parameter (eg. Find all classmates of a user). Obviously I have to respect users privacy settings, so I thought to query against all users with level 2 permissions, however I realise that I may miss out some classmates who are FB friends but have permission levels set to 1. Secondly, I'm looking to find out the relationship between two users (a function that I can plug in 2 user IDs and return their relationship...classmates, FB friends, past classmates, no relationship) which I can then use to determine whether a user has permission to view another users profile. I don't have much code as of yet, because I spent a long time exploring one avenue which I now realise to be the wrong one! Any suggestions/help would be greatly appreciated! This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=318962.0 This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=331047.0 Hello, Greetings! I have php application for restaurant, basically there are two types of orders Kitchen Items and Bar items. A cashier enters a order from customers from computer A (say). We have two computers in kitchen, Computer B and in Bar, Computer C. When cashier from computer A clicks a button, depending upon the order type i need to print a chit on Computer B and/or Computer C. COmputer A, B, C are in same network. All computers have laser printer which can print any type of content. Well i tried to search the forum, i couldn't find anything that would be of my help. Can anyone tell me what would be the starting point for this?? Thanks watsmyname My user needs me to update the database on their server from data contained in a text file but do not want me to upload the text file to the server but rather read the file from wherever it exists. Across the intranet. Uploading the file means that whomsoever needs to do this update requires write permission to a folder on the server & my user does not want that. Suggestions on how I should solve this problem would be greatly appreciated. BTW My code works fine if I upload the file and do the update in place on the server. Hi phpfreaks members, I got a little social network website, http://www.tranceprofile.com I got a php script for members to log in to my website. When they are logged in they can view there own profile and edit it. I got my login script on two places, http:www.tranceprofile.com/login.php and my index.php page. Well here is my problem: When they log in they are send to my index.php page as a logged in user. I want them to be redirected to the http://www.tranceprofile.com/profile.php page. I hope you guys can help me out! Best regards, Mitch Oosterhuis. Login script: <table width="400" align="center" cellpadding="6" style="background-color:#FFF; border:#666 1px solid;"> <form action="login.php" method="post" enctype="multipart/form-data" name="signinform" id="signinform"> <tr> <td width="23%"><font size="+2">Log In</font></td> <td width="77%"><font color="#FF0000"><?php print "$errorMsg"; ?></font></td> </tr> <tr> <td><strong>Email:</strong></td> <td><input name="email" type="text" id="email" style="width:60%;" /></td> </tr> <tr> <td><strong>Password:</strong></td> <td><input name="pass" type="password" id="pass" maxlength="24" style="width:60%;"/></td> </tr> <tr> <td align="right"> </td> <td><input name="remember" type="checkbox" id="remember" value="yes" checked="checked" /> Remember Me</td> </tr> <tr> <td> </td> <td><input name="myButton" type="submit" id="myButton" value="Sign In" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2">Forgot your password? <a href="forgot_pass.php">Click Here</a> <br /></td> </tr> <tr> <td colspan="2">Need an Account? <a href="register.php">Click Here</a><br /> <br /></td> </tr> </form> </table> Hi,
I'm newbie. My requirement is to open network shared folder from PHP.
This works fine in IE but not in Chrome.
Can anyone please help me ....
Thanks
My setup: (everything on a local network) Web server: Ubuntu Server 8.10 -- Workgroup File server: Windows Server 2008 x64 -- domain Test server: Win 2000 running WAMP -- domain I'm trying to run the code snippet below. $file is a file on the File server above. It definitely exists. Running the code below on the Test server works perfectly. But the file cannot be found when running from the Web server. $file = '//server/share/file.txt'; if (file_exists($file)) echo 'yay!'; else echo 'error'; What with the safe mode considerations, I've also tried to add: ini_set('safe_mode', 'Off'); to no effect. And since file, and fopen similarly not work, I'm pretty sure it's not that either. The File & Test servers are on the same Windows domain, but that's definitely not the reason. I tried the code on a file on a Linux computer in the Workgroup (where the Web server is) with the same results: Test server works, Web server does not. Please advise; I'm really lost. I am creating a simple social network, and i want the post visible only on its circle of friends but the problem is... let say user_a, user_b, user_c already registered and user_a and user_c connected/friends already and all their posts and comments are visible on their circle but when user_b write a post oh his wall, it's also visible to user_a and user_c which i dont want to happen. I dont know what was wrong on codes below. CREATE TABLE IF NOT EXISTS `user`( `uid` INT(11) AUTO_INCREMENT PRIMARY KEY NOT NULL, `uname` VARCHAR(25) NOT NULL, `pword` CHAR(60) NOT NULL, `fullname` VARCHAR(30) NOT NULL, INDEX(`uname`) ) Engine = InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci; CREATE TABLE IF NOT EXISTS `friend`( `fid` INT(11) AUTO_INCREMENT PRIMARY KEY NOT NULL, `friend_id` INT(11) NOT NULL, `my_id` INT(11) NOT NULL, `stat` ENUM('0','1') NOT NULL, INDEX(`friend_id`, `my_id`), FOREIGN KEY(`friend_id`) REFERENCES `user`(`uid`) ON UPDATE CASCADE ON DELETE CASCADE ) Engine = InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci; public function viewFriendIfExistOnTbl($uid) { $query = $this->mysqli->query("SELECT `friend_id` FROM `friend` WHERE `my_id` = '$uid' LIMIT 1"); if ($query->num_rows > 0) { return true; } } I recently created an application and tested on my local production environment. the problem I'm having is a cookie gets set with an a session variable. It works on my dev environment and I am able to view it's contents. When I uploaded the files to Network Solutions I receive get this error: Warning: Invalid argument supplied for foreach() in /data/18/1/27/121/1842447/user/1999590/htdocs/includes/session.php on line 55 and when I dump the variable it is empty. The version of php I am using is 5.3 and the version php Network Solutions is using is 5.1. Do you think it could be something with the two different versions of php or could it be a setting on their end. I am a novice php developer and I would appreciate any input thanks. |