Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. LOL, my bad.. that was incorrect, it should of been ([^\[]*), the % just tell preg_replace that the expression has started or ended, the %i means end of the expression and use i (ignore case) the fact i used % doesn't make any differents you could us @ or | or #, anything you don't use in the expression.. \[ = escaped [
  2. download PsTOOLS Get extract psexec, (put it in your %path%) and replace start with psexec -d that should do it
  3. <?php if (validDate($_GET['date_from'])) { echo "valid"; }else{ echo "invalid"; } function validDate($date) { if (preg_match('%((?:19|20)[0-9]{2})[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])%s', $date, $reg s)) { if(checkdate($regs[2], $regs[3], $regs[1])) { $tTime = mktime(0, 0, 0, $regs[2], $regs[3], $regs[1]); return ($tTime < time()); } } return false; } ?>
  4. try this *untested <?php if ($date($_GET['date_from'])) { echo "valid"; }else{ echo "invalid"; } function validDate($date) { if (preg_match('%((?:19|20)[0-9]{2})[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])%s', $date, $regs)) { return checkdate($regs[2], $regs[3], $regs[1]); } else { return false; } } ?>
  5. your comment refers to the line below as a note in my tests that line works fine.. full code.. (your note the die("KILLED") <?php //User inputs // //$side_a = 10 //$side_c = 24 and //$angle_a = 150 (degrees) // $side_a = 10;//$_REQUEST['side_a']; $side_b = 24;//$_REQUEST['side_b']; $side_c = $_REQUEST['side_c']; $angle_a = 150;//$_REQUEST['angle_a']; $angle_b = $_REQUEST['angle_b']; $angle_c = $_REQUEST['angle_c']; $side[0]=$side_a; $side[1]=$side_b; $side[2]=$side_c; $angle[0]=$angle_a; $angle[1]=$angle_b; $angle[2]=$angle_c; $angle[0] = deg2rad($angle[0]); $angle[1] = deg2rad($angle[1]); $angle[2] = deg2rad($angle[2]); SSA($side, $angle); function SSA($side, $angle) { $pi = define_pi(); if (empty($side[0])) { if (empty($angle[1])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[1]) //working! { echo "<BR>No solution because 'side c is less than or equal to side b'.<BR>"; } elseif ($side[2] > $side[1]) //working! { $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[2]*sin($angle[0])/sin($angle[2])); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[1]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[1]) //working! { echo "<BR><i>Two solutions, h < c < b. </i><BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_a2 = $pi - $angle[2] - $angle_b2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[1]) //working! { echo "<BR>One solution, c > h and c > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1] + $side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[1] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = $side[2]*tan($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif (empty($angle[2])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[2]) //working! { echo "<BR>No solution because 'side b is less than or equal to side c'.<BR>"; } elseif ($side[1] > $side[2]) //working! { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[1]*sin($angle[0]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) //working! { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) //working! { echo "<BR>Two solutions, h < b < c."; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) //working! { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) //working! { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = acos($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } } elseif (empty($side[1])) { if (empty($angle[0])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[0]) //working! { echo "<BR>No solution because 'side a is less than or equal to side c'.<BR>"; } elseif ($side[2] > $side[0]) //working! { $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt(($side[0]*$side[0]) +($side[2]*$side[2]) - (2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[0]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[0]) //working! { echo "<BR>Two solutions, h < c < a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $angle_a2 = $pi - $angle[0]; $angle_b2 = $pi - $angle[2] - $angle_a2; $side_b2 = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle_b2))); $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side b<sub>2</sub> = " ,$side_b2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[0]) //working! { echo "<BR>One solution, c > h and c > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[0] = ($pi/2); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = $side[2]*tan($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle C is 90 degrees.<BR>"; $side[1] = sqrt(($side[2]*$side[2]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[2])/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; show_me_the_money($side, $angle); } } } //Side note: when I remove this line (just the '}') I get an "$end" error /// Why does the number of curly brackets not match up correctly -- yet still parses!!! //Line below is part that should be functioning, but isn't... elseif (empty($angle[2])) { if ($angle[0] > ($pi/2)) { die("KILLED"); if ($side[0] <= $side[2]) { echo "<BR>No solution because 'side is less than or equal to side '.<BR>"; } elseif ($side[1] > $side[2]) { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[0]*sin($angle[2]))/sin($angle[2]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) { echo "<BR>Two solutions, h < b < c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[1]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = asin($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } elseif (empty($side[2])) { if (empty($angle[0])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[0]) { echo "<BR>No solution because 'side b is less than or equal to side a'.<BR>"; } elseif ($side[1] > $side[0]) { $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = ($side[1]*sin($angle[2]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[0]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[0]) { echo "<BR>Two solutions, h < b < a ."; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $angle_a2 = $pi - $angle[0]; $angle_c2 = $pi - $angle[1] - $angle_a2; $side_c2 = sqrt((($side[0]*$side[0]) + ($side[1]*$side[1]))-(2*$side[0]*$side[1]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle[2]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[0]) { echo "<BR>One solution, b > h and b > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt((($side[1]*$side[1]) + ($side[0]*$side[0]))-(2*$side[1]*$side[0]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[0] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[1])/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; show_me_the_money($side, $angle); } } } elseif (empty($angle[1])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[1]) { echo "<BR>No solution because 'side a is less than or equal to side b'.<BR>"; } elseif ($side[0] > $side[1]) { echo "<BR>One Solution, a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = ($side[0]*sin($angle[2]))/sin($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[0] < ($pi/2)) { $height = $side[1]*sin($angle[0]); if ($side[0] < $height) { echo "<BR>No solution, the swinging side (a) is shorter than the height.<BR>"; } elseif ($side[0] > $height && $side[0] < $side[1]) { echo "<BR>Two solutions, h < a < c."; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_c2 = $pi - $angle[0] - $angle_b2; $side_c2 = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); $angle_b2 = rad2deg($angle_c2); $angle_c2 = rad2deg($angle_a2); echo "<BR>Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[0] > $height && $side[0] >= $side[1]) { echo "<BR>One solution, a > h and a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[0] == $height) { echo "<BR>One solution, a = height.<BR>"; $angle[1] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); show_me_the_money($side, $angle); } } elseif ($angle[0] == ($pi/2)) { echo "<BR>One Solution, Angle A is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } } function define_pi() { $pi = 3.14159265358979323846; return $pi; } #debug function show_me_the_money() {} ?> EDIT: as a side note, i ran this direct so no REQUEST's we're set
  6. this works for me <?php $user = "Test"; $file = "MyFile.txt"; $CurDir = dirname(__FILE__); $somecontent = "TEST"; $NewDir = "$CurDir/$user"; $filepath = $NewDir."/".$file; if (!file_exists($NewDir) && !is_dir($NewDir) ) mkdir($NewDir, 0755); if( is_dir($NewDir) ) { if (is_writable($NewDir)) { if (!$handle = fopen($filepath, 'w+')) { echo "Cannot open file ($filepath)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filepath)"; exit; } echo "Success, wrote ($somecontent) to file ($filepath)"; fclose($handle); } else { echo "The file $filepath is not writable"; } } ?>
  7. i think it does if you add, to the start <?php // Report all PHP errors (bitwise 63 may be used in PHP 3) error_reporting(E_ALL); // Same as error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ?> anyways.. is that solved ?
  8. <?php //Fetch the row from the database $rowuser = mysql_fetch_assoc($FindUser1); $UserName1 = $rowuser['Username']; //<-- update ?> EDIT: too slow, or thorpe's too quick!
  9. your example didn't escape the ['s this would work data= "[url=test.com]test[/url]"; $result = preg_replace('%\[url=(.*?)\](.*?)\[/url\]%i', "URL=\$1\r\nText=\$2", $data); 1. the Backreferance is in order 2. lazyness from the example above (.*?)\] Now if the Expression was (.*)\] the .* would be greedy and match everything including the ], thats no good.. so we use lazyness .*? which looks ahead and see we want to match a ], thus matches until it see a ] ahead.. i hope this makes sence.. as a side note i would use this code $result = preg_replace('%\[url=([^\]]*)\]([^[]*)\[/url\]%i', "URL=\$1\r\nText=\$2", $data); this thread could go on for weeks, a great book is O'REILLY, Mastering Regular Expression EDIT: the /s means that the . (dot) also mateches new line
  10. is it your server, shared, etc ? has the mail been setup in PHP.INI, ie pop3_server=mail.yourdomain.com pop3_username=you@yourdomain.com pop3_password=mysecretpassword ; if your smtp server requires authentication, modify the following two lines ;auth_username= ;auth_password=
  11. try this <?php session_start(); $username = $_SESSION['userName']; $file = $_POST['file']; $curpath = dirname(__FILE__); $filename = "$curpath/$username/$file"; $somecontent = "This is a new file"; echo (chmod($curpath."/".$username, 0777))?"":"chmod failed"; if (is_writable($filename)) { if (!$handle = fopen($filename, 'w+')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "<font face='verdana' size='2'><center>File $file created! Edit it <a href='writenew.php?file=$file'>Here</a>"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> or use can use chdir($username);
  12. "doesn't work" isn't usefull the reason it "doesn't work" is because its broken try my example and give more info please
  13. Like this! assuming that the folder sites/test/ exists <?php $username = "test"; $filename = "sites/$username/"; $somecontent = "Blar\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w+')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?>
  14. okay.. lets try this <?php echo "World"; include "..\test3.php"; ?> also on test1.php add this echo $_SERVER['DOCUMENT_ROOT']; PHP include path, means where it searches for the included files if their not found..
  15. if you wanted to you could recompiling PHP using the shared memory module for sessions, or use a RAM Disk. Enable this with "configure -–with-mm" then re-compile PHP, and set session.save_handler=mm in php.ini.
  16. lets try something new 2 files, upload into same folder and run test1.php <?php echo "Hello "; include "test2.php"; ?> <?php echo "World"; ?> if that works (and it should) create a folder called "TEST" and move test2.php into it, and change test1.php to <?php echo "Hello "; include "TEST/test2.php"; ?> try that.. thats should also work.. NOW create a new file called "test3.php" in the same place as "test1.php" <?php echo "Woohoo"; ?> and update test2 to <?php echo "World"; include "../test3.php"; ?> Lets see what happens
  17. worth a shot.. try include dirname(__FILE__)."\..\functions.php"; or include realpath(dirname(__FILE__) . "/functions.php"); or include realpath(dirname(__FILE__) . "\functions.php");
  18. SAFE MODE = more secure.. LMAO.. well they say that.. why are you trying to access a file create by another user anyway ? if they where the same your be okay even with safe mode!
  19. so index.php functions.php Shoutbox --posting.php OK if include "../functions.php"; doesn't work try this include dirname(__FILE__)."/../functions.php";
  20. try this sample script <?php //test $Name = $_FILES['testfile']['name']; $Size = $_FILES['testfile']['size']; //Test Check if(valid_ext($Name)) { echo "valid ext"; }else{ echo "invalid"; } echo "<br>"; if(valid_size($Size)) { echo "valid size"; }else{ echo "invalid"; } //***FUNCTIONS //filter extensions function valid_ext($file_name) { $valid = array("jpeg","jpg","jpe","png","gif"); $extension = strtolower(substr($file_name,-3,3)); return (in_array($extension, $valid)); } //filter by size, function valid_size($size) { return ($size <= 1048576); } ?>
  21. Okay.. you may need to change the access right of the public_html, do you know what they are set to ? or the server may have some restrictions.. i guess you could try via FTP.... <?php $file = "test.txt"; $ftpUserName = 'username'; $ftpUserPass = 'userpass'; $ftpServer = 'ftp.example.com'; $ftpConn = ftp_connect($ftpServer); if (!$ftpConn) { die("Unable to connect to $ftpServer"); } if (@ftp_login($conn_id, $ftpUserName, $ftpUserPass)) { echo "Connected as $ftpUserName @ $ftpServer"; } else { echo "Couldn't connect as $ftpUserName"; ftp_close($ftpConn); die("Closed connection to $ftpServer"); } echo ftp_chmod($ftpConn, 0777, $file) ? "CHMOD successful!" : 'Error'; // try to delete $file if (ftp_delete($ftpConn, $file)) { echo "$file deleted successful\n"; } else { echo "could not delete $file\n"; } // Close the connection ftp_close($conn_id); ?>
  22. Show use.. ie Index.php function.php Tests --test1.php --test2.php --test3.php --Old ----test1.php Docs --doc1.doc etc from that example test1.php would include function.php like this include "../function.php";
  23. change if(file_exists($path . $file_name) || !valid_ext($file_name)) { to if(file_exists($path . $file_name) ) { *note, i haven't read the whole thread
  24. Yeah i got one, CAUSE: $handle = fopen("$file", "x+"); Warning: fopen() [<a href='function.fopen'>function.fopen[/url]]: SAFE MODE Restriction in effect. The script whose uid/gid is 1051756/1051756 is not allowed to access /home/users/uks51756/html/games4uonline.com/sites/mattal999 owned by uid/gid 33/33 in /home/users/uks51756/html/games4uonline.com/sites/new2.php on line 7 FIX: turn off SAFE MODE
  25. if your not passing a file then why check for the file ? just move the code that updates the mysql out of the routine that check for the files and, add a new checking routine to check if the entries are blank..
×
×
  • 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.