Jump to content

putty

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

putty's Achievements

Member

Member (2/5)

0

Reputation

  1. putty

    Hide email

    The problem is that the code is coming out of the CMS as plain text with the emails within the text Example: $content = " Some test text with email1@domain.com two email address email2@domain2.com, there could be many many email addresses. "; $content = new SpiderTrap($content); class SpiderTrap{ public function __construct($content){ return $this->emailFilter($content); } public function emailFilter($content){ $search = "~[\s]+([^\s]+@[^\s]+)[\s]+~iUs"; // Find the tags preg_match_all($search, $content, $matches); // Loop through each tag for ($i=0; $i < count($matches['0']); $i++) { $value = $matches['1'][$i]; $email = $this->email2ascii($value); $content = str_replace($value, $email, $content); } return $content; } function email2ascii($email){ $asciiEmail = ''; $lenght = strlen($email); for($i = 0; $i < $lenght; $i++){ $asciiEmail .= '&#' . ord($email[$i]) . ';'; } return $asciiEmail; } } The problem is with the regular expression, it only ever finds the first email. Is there anyone who has some skill with regular expression who can help me out?
  2. In an attempt to automatically hide my email from spam bots, I have been working on a script that turns all email on a page into ASCII, however I am having trouble with one little bit of code. Douse anyone have a script that can return all emails within a string as an array? Cheers.
  3. Ok the problem seems to be with “php_value session.auto_start” if I use session_start(); instead it seems to work, however I get a warning, Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/duguljambula/index.php:1) in /var/www/duguljambula/index.php on line 2 I can hide this warning with @session_start() and everything works. I don’t understand what is causing this warning and it may cause problems down the road. session_start(); is the first thing called in my script, before headers are sent. <?php session_start(); require_once('./config.php'); //Header require_once(_ABSPATH . 'content/layout/header.php'); $PAGE = $_INPUT[2]; if(!$PAGE){ $PAGE = 'index'; } if(file_exists(_ABSPATH . 'content/pages/'. $PAGE . '.php')){ include_once(_ABSPATH . 'content/pages/'. $PAGE . '.php'); }else{ include_once(_ABSPATH . 'content/error/404.htm'); } //footer require_once(_ABSPATH . 'content/layout/footer.php'); ?> I am using RewriteEngine to pass every script via the index page. Eg, “www.mysite.com/map” will call index.php with the page variable ‘map’ however I still get the same warning if I call the script directly .eg, www.mysite.com/index.php?page=map Any thoughts or suggestions? It doesn’t seem to make any difference it I authenticate using AJAX or just in the index script. Thanks for the suggestion.
  4. I am having trouble keeping a session variable, I have a login script that when authenticated sets $_SESSION['uid'] = $uid; $_SESSION['password'] = $password; I am using “php_value session.auto_start” set in my htaccess.dist file to automatically start my session for every page. The problem is that the session value is not held if I navigate to another page $_SESSION['uid'] is empty. Any suggestions why? Is this something to do with “php_value session.auto_start”? Any help or suggestions of how to debut this problem would be much appreciated, my application goes live at the end of the week and I don’t think my users will appreciate having to type there username and password on every page. PS. I am using AJAX to call my authentication script, if that makes a difference. Thanks in advance, Levi
  5. I am creating a simple File Locking/Version Control system on a project I am working on. I have been using the database to check files in and out and stop users from overwrite each other's changes, however I wanted to put an additional level of security on the files themselves. Is there a function or method similar to Flock() that can hold a lock on a file longer than just the script execution time? Thanks, Levi
  6. This application has a complex directory structure, I just found it an easy way to keep track of script paths Include('http://' . $_SERVER["HTTP_HOST"] . '/include/gui/tables.php) Is simpler to read than Include(../../../../include/gui/tables.php) i just like reading paths from the root derectory. I usualy include paths like this define('ABSPATH', dirname(__FILE__).'/');//setup in my config.php Include(ABSPATH . 'include/gui/tables.php)//include from in all other php files if you have a better approach I would love to see. PS, Problem solved PHP just need to be recompiled with apache.
  7. Ok I have been running a script for several months now and all of a sudden I get a 500 error. I think this error corresponds to the server admin upgrading there version of php. I have tracked down the problem to my 'required_once' statements. the php script included by the 'required_once' is executing however no variables set in the included script are being passed back to the including script. Example. index.php <?php require_once('http://' . $_SERVER["HTTP_HOST"] . '/settings/dj-config.php');// Configuration and Global variable Declarations echo 'ROOT = ' . ROOT . '<br>'; echo '$root = ' . $root . '<br>'; ?> dj-config.php <?php define (ROOT, 'http://' . $_SERVER["HTTP_HOST"] . '/'); $root = 'Hello Would!'; ?> Run Script ROOT = ROOT $root = Both allow_url_fopen and allow_url_include are turned on, Are there any other php settings that could be causing this behaviour? Thanks, Levi
  8. Ok the original message seems to have been deleted by the moderators so I will have another go at explaining my problem. I want to get all the comments out of a comment block in a particular script. The comment block looks like this <?php /** * @function: updatePage * * @Description: * Updates the page name and content * * @Parameters:4 * @Param-1:$id - int - the id number of the page to update * @Param-2:$name - varchar - the the new name to update * @Param-3:$content - varchar - the new content to update * @Param-4:$priority - int - the priority of this page, the lower the value the sooner it will be desplayed in the link bar * * @return bool - return True if page content was updated and False if there was an error */ function updatePage($id, $name, $content, $priority){ ... ?> I want to return this * @function: updatePage * * @Description: * Updates the page name and content * * @Parameters:4 * @Param-1:$id - int - the id number of the page to update * @Param-2:$name - varchar - the the new name to update * @Param-3:$content - varchar - the new content to update * @Param-4:$priority - int - the priority of this page, the lower the value the sooner it will be desplayed in the link bar * * @return bool - return True if page content was updated and False if there was an error This is what I have tried with little success. <?php preg_match_all('/\/\*\*(.*?)\*\//', $content, $matches); // Loop through each tag for ($i=0; $i < count($matches['0']); $i++) { echo $matches['1'][$i]; echo "<hr>"; } ?> Please help this problem has been bugging me down all day Thanks, Levi Putna
  9. Sorry double post, Moved to : http://www.phpfreaks.com/forums/index.php/topic,168864.0.html
  10. Ok I came across cURL, but before I spend time working out how to compile it can anyone tell me if it will solve my problem? And if someone can give me an example of how to use cURL to authenticate a proxy, that would be great. I think it is something like this… <?php $url = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&srs=EPSG:4326&bbox=110,-45.5,160,-8&WIDTH=1280&HEIGHT=960&format=image/jpeg "; $cUrl = curl_init(); curl_setopt($cUrl, CURLOPT_URL, $url); curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($cUrl, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($this->cUrl, CURLOPT_PROXY, '147.***.***.***:8080'); curl_setopt($this->cUrl, CURLOPT_PROXYUSERPWD, 'test_user:test_password'); $PageContent = curl_exec($cUrl); $file = file_get_contents($url); $path = "./map/test.jpg"; if(file_put_contents($path,$file)){ //desplay image } else{ // error handeling } curl_close($cUrl); ?>
  11. I have tried <?php $opts = array('http' => array('proxy' => 'envproxy.env.qld.gov.au:8080')); $context = stream_context_create($opts); $url = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&srs=EPSG:4326&bbox=110,-45.5,160,-8&WIDTH=1280&HEIGHT=960&format=image/jpeg "; $file = file_get_contents($url, false, $context); $path = "./map/test.jpg"; if(file_put_contents($path,$file)){ echo "Yahoooooo"; } else{ echo "NOOOOOO" } ?> This connects throw a proxy but doesn’t handle any user name and password authentication. I have never tried to do anything line this before can someone please help me out. Thanks.
  12. Am working behind a prox, this is causing problems when I try to save an image from another server. Dose anyone know how to authenticate (user name and password) and run this code? <?php $url = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&srs=EPSG:4326&bbox=110,-45.5,160,-8&WIDTH=1280&HEIGHT=960&format=image/jpeg "; $file = file_get_contents($url); $path = "./map/test.jpg"; if(file_put_contents($path,$file)){ //run map script } else{ //log error } ?>
  13. Am working behind a prox, this is causing problems when I try to save an image from another server. Dose anyone know how to authenticate and run this code? <?php $url = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&srs=EPSG:4326&bbox=110,-45.5,160,-8&WIDTH=1280&HEIGHT=960&format=image/jpeg "; $file = file_get_contents($url); $path = "./map/test.jpg"; if(file_put_contents($path,$file)){ //run map script } else{ //log error } ?> Thanks in advance.
  14. putty

    Save image

    sorry I did know that I was talking about this bit of code, <?php $url = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&srs=EPSG:4326&bbox=110,-45.5,160,-8&WIDTH=1280&HEIGHT=960&format=image/jpeg "; $file = file_get_contents($url); $path = "./map"; if(file_put_contents($path,$file)){ echo "Yahoooooo"; } else{ echo "it didn't Work"; } ?> $file is empty after running $file = file_get_contents($url);
  15. putty

    Save image

    Ok got the file_get_contents($url) working, needed to change a few setting on our server. Now the problem is that file_get_contents($url) doesn’t return anything. Did you get any return data from file_get_contents($url)?
×
×
  • 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.