cereal 1,524 Nearly a Senior Poster Featured Poster

Show your code. Also PAM extension is working for you? You can install it also via apt:

sudo apt-get install php5-auth-pam

then try:

pam_auth('username','password',&$error);
echo $error;

pam_auth() will return boolean true on login, otherwise you can display the errors by echoing the third argument &$error.

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm glad you solved.

In addition you cannot perform a self extraction and you cannot perform a command like system('unzip html.zip'); from an ftp shell, nor from ftp_exec() because is chained to the FTP server interface, but you can change your approach:

  1. you first send a file (pong.php) to retrieve information of the remote system (Server2)
  2. basing on the received information you use a new ftp connection to send an archive to Server2, which can be for example: archive.zip or archive.php.gz
  3. use the newe retrieved informations to send a curl request to pong.php file so it can perform the extraction of the files

For the zip files you can use ZipArchive which is based on zip extension, for gz you need zlib library which is needed also by ZipArchive. While a zip can contain many files, gz can compress only single files, but you can use base64_encode() to convert file contents to strings, save them as an array inside a single file (archive.php.gz) and then perform an extraction.

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome. What happens? The link is not displayed?

By placing it right after the ftp_close() it should work:

ftp_close($conn_id);
echo '<p><a href="another-file.php">Go back to the main page</a></p>';

To perform an automatic redirect, after displaying the output of the operation you can add a meta tag to the page. To simplify you can add an array to the top of the script $output = array(); and change all the echo statements to $output[] = 'message goes here'; and then print the output at the end.

Otherwise you can save $output to $_SESSION, redirect with header() to the form page and display the results.

cereal 1,524 Nearly a Senior Poster Featured Poster

In order to work you have to create an array and then loop it into single ftp_put() calls, so change the form so you can send an array of files, i.e. by changing the name attribute of the input field userfile:

<tr>
    <td align="left" valign="top">
        Select your file to upload:
    </td>
    <td>
        <input name="userfile[]" type="text" size="50" value="a.html" /><br />
        <input name="userfile[]" type="text" size="50" value="b.html" /><br />
        <input name="userfile[]" type="text" size="50" value="c.html" />
    </td>
</tr>

And change the script:

<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    # verify the files
    function checkfiles($path,$files,$default_files)
    {
        $result = array();

        if(count(array_filter($files)) == 0)
        {
            # default array of files, loaded in case $_POST['userfile'] is empty
            $files = $default_files;
        }

        foreach($files as $file)
        {
            $file = pathinfo(parse_url($file,PHP_URL_PATH),PATHINFO_BASENAME);
            if(file_exists($path.$file) && is_file($path.$file))
            {
                $result[] = $file;
            }
            else
            {
                echo "<p>file $file not found!</p>";
            }
        }
        return $result;
    }

    # default array of files
    $default_files = array('a.html','b.html','c.html','d.html','e.html');

    # variables for local server
    $local_path = $_SERVER['DOCUMENT_ROOT'].'/ftp/'; # change this to match yours
    $local_files = checkfiles($local_path,$_POST['userfile'],$default_files);

    if(count($local_files) == 0)
    {
        echo '<p>Error, files not founded!</p>';
        exit;
    }

    # ftp credentials and remote path
    $ftp_user_name = $_POST['user'];
    $ftp_user_pass = $_POST['password'];
    $ftp_server = $_POST['server'];
    $ftp_port = in_array(intval($_POST['port']),array(0,1)) ? 21:intval($_POST['port']); # default port 21
    $remote_path = rtrim($_POST['pathserver'],'/');

    // set up a connection to ftp server
    $conn_id = ftp_connect($ftp_server,$ftp_port);

    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

    if ((!$conn_id) || (!$login_result))
    {
       echo "<p>FTP connection has encountered an error!</p>";
       echo "<p>Attempted to connect to $ftp_server for user $ftp_user_name....</p>";
       exit;
    } else { …
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, the second and third errors are related to the index.php file, you don't need the <?php and ?> since it's plain html, so your index page becomes something like:

<!DOCTYPE html>
<html>
    <head>
        <title>ftp test</title>
    </head>
    <body>
        <h2 align="center">FTP form</h2>
        <form action="step-1-upload.php" method="POST">
            <table align="center">
                <tr>
                    <td align="left">
                        Server:
                    </td>
                    <td>
                        <input size="50" type="text" name="server" value="" />
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Port:
                    </td>
                    <td>
                        <input size="50" type="text" name="port" value="21" />
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Username:
                    </td>
                    <td>
                        <input size="50" type="text" name="user"  value="" />
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Password:
                    </td>
                    <td>
                        <input size="50" type="text" name="password" value="" />
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Path on the server:
                    </td>
                    <td>
                        <input size="50" type="text" name="pathserver" value="public_html/" readonly />
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        Select your file to upload:
                    </td>
                    <td>
                        <input name="userfile" type="text" size="50" value="a.html" />
                    </td>
                </tr>
                <tr>
                    <td align="left" colspan="2" height="1">
                    </td>
                </tr>
                <tr>
                    <td align="left">
                    </td>
                    <td>
                        <input type="submit" name="submit" value="Start Installation" />
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

The other two errors are occuring because the paths are not defined, in my previous example I was checking if the file existed, but when setting $filep I wasn't adding the local path, probably this caused your error, anyway here's a working version:

<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    # variables for local server
    $local_path = $_SERVER['DOCUMENT_ROOT'].'/ftp/'; # change this to match yours
    $filename = pathinfo(parse_url($_POST['userfile'],PHP_URL_PATH),PATHINFO_BASENAME);

    # ftp credentials and remote path
    $ftp_user_name = $_POST['user'];
    $ftp_user_pass = $_POST['password'];
    $ftp_server = $_POST['server'];
    $ftp_port = in_array(intval($_POST['port']),array(0,1)) ? 21:intval($_POST['port']); # default …
cereal 1,524 Nearly a Senior Poster Featured Poster

Which errors you get? As suggested by c-tech you can use a conditional statement to submit the default value and use the form to only display the file name. Also, change your form to deal with strings and not with uploads, for example this:

<input name="userfile" type="file" size="50" value="a.html">

should be:

<input name="userfile" type="text" size="50" value="a.html">

since there are no uploads from the browser client to Server1, $_FILES will be empty, you don't need it because the script gets the file name from the $_POST array, for example:

# $filep=$_FILES['userfile']['tmp_name']; # remove this line
$file = pathinfo(parse_url($_POST['userfile'],PHP_URL_PATH),PATHINFO_BASENAME);
$path = '/local/path/';

if(file_exists($path.$file))
{
    $filep = $file;
}
else
{
    $filep = 'a.html';
}

Anyway, be more specific about the errors, so we can try to help you, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Pretty clear, thank you for the hints!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello there!
I noticed a little bug. I was trying to write a nested list, like this one:

* Item One
* Item Two
    1. Item One
    2. Item Two
* Item Three

I'm not sure this is related, it appears almost fine in the preview box, but it adds automatically an empty line between 1. Item One and 2. Item Two:

34cf556f9e043dc5398697d618224786

When going to submit I get this error:

The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or curly braces.

Also, I thought the absence of an empty line before and after a presumed "code block" as a nested list, would have avoided the check.

cereal 1,524 Nearly a Senior Poster Featured Poster

Oh, ok. In this case you don't have to use $_FILES, since it's not an upload action, but a download from a remote server. So you don't need a file input field, use text field:

<input type="text" name="link" value="http://remote.dev/a.html" readonly />

In addition from your script you should check if:

  • link is valid and allowed
  • if the remote file is available
  • and then you download it

Keep in mind that, even by placing readonly attribute to the field, the client can change the value of the form or try to submit a custom request by itself, by using cURL and submit whatever, so you should also:

  • add a CSRF check;
  • create a download queue list, to avoid multiple concurrent downloads;
  • create a whitelist and check if the source server is allowed;
  • get the header of the file and from there: 1. check the sizes of the file from the header response; 2. check the mime type of the file you are going to download;
  • check the downloaded file (size and mime type) again;
  • save the file inside a directory in which PHP is not executed.

Some info:
http://www.daniweb.com/web-development/php/threads/449496/my-site-was-hacked-by-c99-shell/
http://www.daniweb.com/web-development/php/threads/426854/how-to-create-an-image-downloader

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Check the documentation, there is a good example: http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm not sure this is still possible, since modern browsers works in a sandbox, separated from the system, so you cannot execute or copy a local file directly from a remote script.

cereal 1,524 Nearly a Senior Poster Featured Poster

The only thing I can think is to check Apache logs and if also the other files and directories are owned by the same user running Apache. Or it could be the browser cache, you can try to run cURL to check if you get the page or an error:

curl --head http://localhost/page

Or, from the browser, append a random number to the link: http://localhost/page?2134

I don't have any other ideas, good luck!

cereal 1,524 Nearly a Senior Poster Featured Poster

Those functions are not for MySQL, you have to use CONVERT_TZ(): https://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_convert-tz

You can also change the database time zone, for example:

SET GLOBAL time_zone = 'UTC';

http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html

cereal 1,524 Nearly a Senior Poster Featured Poster

The configuration seems fine to me. It could be an ownership/permission issue for the .htaccess file, check it with:

ls -l .htaccess

The owner and the group should be the user that runs apache, usually www-data and as permission you can use 644, so:

sudo chown www-data:www-data .htaccess
sudo chmod 644 .htaccess
cereal 1,524 Nearly a Senior Poster Featured Poster

Did you reload Apache after changing /etc/apache2/sites-available/default? To do that run:

sudo service apache2 reload
cereal 1,524 Nearly a Senior Poster Featured Poster

I see. That probably happens because MySQL bin directory is not added to the system path, I'm not sure it's possible to add a flag to include it during the installation process, right now I don't remember. But you can edit the Windows Enviroment Variables: http://docs.oracle.com/cd/E17952_01/refman-5.5-en/windows-start-service.html

That way it becomes easy to execute the commands, because the system knows where the bin directory is located. Anyway, mine was only an alternative solution. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use SimpleXML:

<?php

    $link = file_get_contents('http://remote.tld/file.xml');
    $xml = simplexml_load_string($link);
    print_r($xml);

This will return an object, that you can use as example: echo $xml->totalresults;

cereal 1,524 Nearly a Senior Poster Featured Poster

Raja please use appropriated titles: http://www.daniweb.com/community/rules
This is the fifth thread you start with the same generic title.

cereal 1,524 Nearly a Senior Poster Featured Poster

To avoid the reinstall you can also run:

mysqladmin -uroot password new_password

Where password is a command and new_password his value. After you set the root password you can log into the server: http://dev.mysql.com/doc/refman/5.5/en/mysqladmin.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Exactly what is the problem? Which version are you trying to install and which platform are you using? For more information read: http://dev.mysql.com/doc/refman/5.1/en/installing.html

cereal 1,524 Nearly a Senior Poster Featured Poster

You can include external libraries by using $this->load->library() or by placing an __autoload() inside /application/config/config.php.

But in order to work:

  • jformer.php classes needs to be splitted one class per file;
  • you need to include the abstract class JFormComponent apart;
  • and you have to save the files into /application/libraries/ if using the loader library, or /application/third_party/ for include, require and __autoload().

However, this is not an easy result to achieve, at least for me, without a modify of jformer.php. If you are trying to use it only for validation purpouses, why don't you use the internal validation library?

Anyway, I'm sorry I cannot help much more on this.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can include it in the Controller construct:

class Test extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        include($this->input->server('DOCUMENT_ROOT').'/application/third_party/jformer.php');
    }

But I'm not sure if it will work properly.

cereal 1,524 Nearly a Senior Poster Featured Poster

Show your code, it will be easier to understand the problem.

cereal 1,524 Nearly a Senior Poster Featured Poster

Innamorato is an italian word, the correct transcription is with two nn, so innamorato not inamorato. The text seems to be this:

Innamorato
Mission
Music
Masculinity
Master of the Art
Music
Who is this music that which description may never justify
Can the ocean be described?
Fathomless music
Body of all that is live at the lastingly
Man initiate innamorato
Your music are tomorrows on know none-life
I love tomorrow

But I'm not sure, especially about fathomless, which ironically is perfect for this text.. :D

cereal 1,524 Nearly a Senior Poster Featured Poster

Which requirements are needed by your provider? For example, here in Italy the most common max speed is about 20Mbps, so it's enough an ADSL2+ router which supports up to 24Mbps in downstream and a device like a Linksys WAG200G works fine: http://support.linksys.com/en-us/support/gateways/WAG200G

cereal 1,524 Nearly a Senior Poster Featured Poster

Are you using CodeIgniter Session library? If yes then autoload it, go to /application/config/autoload.php and go to Auto-load libraries block:

$autoload['libraries'] = array('database','session');

Otherwise load it inside the construct of the Controller. For example, use this controller:

class Test extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->library('session');
    }

    # your functions here

    public function index()
    {
        $d['name'] = $this->session->userdata('name');
        $this->load->view('/test/index',$d);
    }

    public function name($name)
    {
        $data = array(
            'name' => $name
            );
        $this->session->set_userdata($data);
        redirect('/test');
    }

}

Inside /application/views/test/index.php write:

<?php

    echo $name;

?>

Load http://localhost/test/name/shakayu

The application loads Test::name() and registers the value to CI session, after that you are redirected to the index and you get the saved value. This is just an example, when you do the log in process, just retrieve the name of the user from the database and save the value to session by using $this->session->set_userdata($array);

More info: http://ellislab.com/codeigniter/user-guide/libraries/sessions.html

diafol commented: Missed the CI bit! :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster

There is a flaw in my previous answer: if the other users are able to change their virtuahost, they can add the mod_fastcgi handler to their config file or to an .htaccess and override your scripts.

To fix this you could:

  • install php5-fpm
  • install Nginx
  • host your website in Nginx
  • make Nginx listen on a different port as 8000

So, you can use PHP-FastCGI through Nginx. Logically you have to remove mod_fastcgi and proxy_fcgi_module from Apache, so the users will not be able to add the handler or to redirect requests to FastCGI server.

To install Nginx run:

sudo apt-get install nginx

then create your virtual host:

sudo nano /etc/nginx/sites-available/my_server

and add a basic configuration:

server {
    listen 8000;
    server_name mywebsite.dev;

    access_log /var/log/nginx/mywebsite.access.log;
    root /var/www/mywebsite;

    location / {
            index index.php index.html index.htm;
    }

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/tmp/php.socket;
    }
}

Then save the file, enable it and reload the server:

sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/mywebsite
sudo service nginx reload

Besides, I would run the users inside separated chroot environments, so they cannot access to your document root or each others, by simply changing theirs.

Question: .htaccess is not enough for your friends? You can do almost everything from there a part changing the DocumentRoot http://httpd.apache.org/docs/current/howto/htaccess.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Hmm, I didn't tested this, but you could use php-fpm to start a FastCGI socket and assign a specific uid and gid to it, read:

  1. http://wiki.apache.org/httpd/PHP-FPM
  2. http://php.net/manual/en/install.fpm.install.php
  3. http://www.php.net/manual/en/install.fpm.configuration.php
  4. http://www.howtoforge.com/using-php5-fpm-with-apache2-on-ubuntu-12.10

If you have linux ubuntu and PHP5 run:

sudo apt-get install php5-fpm libapache2-mod-fastcgi

then edit the php.ini related to fpm:

sudo nano /etc/php5/fpm/php.ini

And add a user and a group (previously created) specific for the FPM processes:

user string
group string

Change your scripts so they are owned by this new user and setup your virtual host to listen the FPM socket:

<VirtualHost *:80>
    ...
    <IfModule mod_fastcgi.c>
        AddHandler php5-fcgi .php
        Action php5-fcgi /php5-fcgi
        Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
        FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
    </IfModule>
</VirtualHost>

So, at the end, the other virtual hosts will run the normal Server API: Apache 2.0 Handler and yours the FPM/FastCGI, you can check it with phpinfo(). Hope it helps, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Generate an application password and use that to sign in through SMTP: http://support.google.com/a/bin/answer.py?hl=en&answer=1032419

cereal 1,524 Nearly a Senior Poster Featured Poster

It may be a wrong path to the local file, make sure you use absolute paths:

$file = $_SERVER['DOCUMENT_ROOT'] . '/path/to/file.ext';
cereal 1,524 Nearly a Senior Poster Featured Poster

Also mysql.log.1 is not the current log file, it's an old copy, so it can be moved to another location for further analysis or deleted, the main in use is mysql.log. Since it's a general log you can stop it, by commenting the line related to the general_log_file.
Just enable: error.log, mysql-slow.log and expires_logs_days, so you can limit the amount of data. To edit these options run:

sudo editor_of_choice /etc/mysql/my.cnf

Example settings:

#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
log_error = /var/log/mysql/error.log
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
expire_logs_days = 10

Reload mysql after you've done.

OsaMasw commented: AWESOME +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Yes you can: http://www.daniweb.com/members/edit_membership Click on Permanently Delete Membership and the account will be locked. However I don't see anymore the option on the profile page.

More info: http://www.daniweb.com/community-center/daniweb-community-feedback/threads/433570/how-do-i-end-this-membership

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried union all?

(select * from table1 where field1 = 'value to search') union all (select * from table2 where field1 = 'value to search') union all (select * from table3) order by field1;

Read this: http://dev.mysql.com/doc/refman/5.0/en/union.html

cereal 1,524 Nearly a Senior Poster Featured Poster

@CodeAngry
I tried to adapt my code to yours, now it's much better:

<?php
$function_names = array('myvalueone','myvaluetwo','myvaluethree','myvaluefour','myvaluefive');
$functions = array();
foreach($function_names as $function_name){

    ${$function_name} = function($name = false) use ($function_name){ // <-- USE
        return 'The name of the function is ', ($name === false ? $function_name:$name), PHP_EOL;
    };
}

echo $myvalueone();
echo $myvaluetwo('hello');
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome and thank you for sharing the solution :)

cereal 1,524 Nearly a Senior Poster Featured Poster

@sandeepek a suggestion: change the password of your gmail account, since it's included in the above script.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yup, check if in ~/.config/geany/colorschemes/ there are files and set one of those as default, for example: color_scheme=github.conf, include the extension, if there aren't any files then you have two choices:

  1. reinstall Geany, so uninstall the programm and delete the configuration folder under your profile, i.e. ~/.config/geany/, not the .config directory itself, because it contains other software data;
  2. download some themes and save them to the colorschemes directory and edit geany.conf.

Note: I'm suggesting to edit geany.conf because the switcher interface doesn't work properly. Hope it helps, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Since it's a library directory another solution is to .htaccess:

Order allow,deny
deny from all

this will return 403 Forbidden to any direct web access, but the files will still be available for include(), require() and require_once().

cereal 1,524 Nearly a Senior Poster Featured Poster

Check the color scheme inside .config/geany/geany.conf. Before editing the value, close Geany otherwise the current window will overwrite your changes.

cereal 1,524 Nearly a Senior Poster Featured Poster

The problem is that the loop goes to overwrite the function value and even the name. But this seems to work fine for me:

<?php
$myarray = array('myvalueone','myvaluetwo','myvaluethree','myvaluefour','myvaluefive');
$n=count($myarray);
for($i=0; $i < $n; $i++)
{
    define('FUNCTIONNAME'.$i,$myarray[$i]); # define the value
    ${$myarray[$i]} = create_function('$name = FUNCTIONNAME'.$i, 'return "The name of the function is ". $name;');
}
echo $myvaluefive();
echo "\n";
echo $myvalueone();
?>

Output:

The name of the function is myvaluefive

The name of the function is myvalueone

I tried also __FUNCTION__ instead of $name but it outputs __lambad_func or closure depending on the methods: create_function or anonymous functions. Hope it helps.

cereal 1,524 Nearly a Senior Poster Featured Poster

That code should not be considered as a correct snippet, as will work only if register_global is on, a condition that enables everyone to overwrite any variable with get, post, cookie call... fortunately register_globals is going to be removed.

More in general, for everyone, use superglobals as suggested by IIM: http://www.php.net/manual/en/language.variables.superglobals.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, it's a replacement. If the validation fails it returns boolean false, so you may want to add a condition to your script, to match false cases, or set up a flag to alter the execution of the script, just remember to trim the values you get from the form, because the validation can fail.. do something like:

$from = trim($_POST['Email']); # removing spaces from the beginning and end of the string
$from = filter_var($from,FILTER_VALIDATE_EMAIL);

Also consider that filter_var() can be used to sanitize, not only to validate, just check the types of filters from the previous link. It becomes important if, in case of errors, you decide to display the values back in the form. If not sanitized an attacker can execute his own code, for example:

$FirstName = 'hello <script>alert("wide")</script> world'; # got from $_POST['FirstName']
echo filter_var($FirstName,FILTER_SANITIZE_STRING);

will print: hello alert(&#34;wide&#34;) world, otherwise the javascript would be excuted. The above, in practice, removes the tags and encodes special characters.

cereal 1,524 Nearly a Senior Poster Featured Poster

Is it best just to remove the following line of code? If its not then whats the best solution for validating that?

If you have PHP 5.2.0 or higher then use filter_var(): $from = filter_var($_POST['Email'],FILTER_VALIDATE_EMAIL); Otherwise use preg_match() to validate the email.

For more information check: http://www.php.net/manual/en/function.filter-var.php

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, this $from = $_REQUEST['Email']; is not good to use: 1) there is no validation and 2) because an attacker can use $_GET or $_COOKIE to inject is own code.

cereal 1,524 Nearly a Senior Poster Featured Poster

Check your IF statements, this <src="index.php?lang=nl"> is not a tag, so you have to change them all, also there is no default condition.

cereal 1,524 Nearly a Senior Poster Featured Poster

It has nothing to do with the code that cereal and I provided.

Sorry LM but the code I wrote is exactly to check who and when reads the newsletters (when the images are enabled in the HTML version). The key is to use unique image links for each recipient, or at least different links for each campaign. This can be done easily if the used platform provides the correct instruments.

For example: MailChimp provides an API which allows to submit contents from a personal interface, so the image links can be autogenerated by a script, otherwise (more easier) there is the chance to create unique links to a remote image by using their Merge Tags mechanism, and include them in the template, something like:

http://my_webserver.tld/img/*|CAMPAIGN_UID|*/*|EMAIL|*/dot.jpg

will become:

http://my_webserver.tld/img/23/abc@cba.com/dot.jpg

And when a user opens the HTML version of the newsletter, will perform a GET connection to our server and load the script that renders the remote image, throught that you can solve the problem. I hope this is useful, I don't know which service is used by the OP, but this it may give an hint.

For more information check this: http://kb.mailchimp.com/article/can-i-create-a-different-link-for-each-recipient-using-the-merge-tags

Bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

A simple method, for example, is this:

<?php
    # declare variables to register
    $path = '/images/';
    $image = $_GET['image'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $browser = $_SERVER['HTTP_USER_AGENT'];
    $date = date('Y-m-d G:i:s');
    $cid = $GET_['campaign_id']; # so you can identify the newsletter
    $ucode = $_GET['user_code']; # so you can identify each user opening the newsletter

    # check if variables contents are true
    if(/* check */) # true
    {
        // database connection . . .

        $q = "insert into newsletter_stats (`ip`,`browser`,`open_date`,`campaign_id`,`user_code`) values('$ip','$browser','$date','$cid','$ucode')";

        # insert data
        mysql_query($q) or die(mysql_error()); # consider using mysqli
    }

    # display the image, this could be a simple image 1x1 or your company logo
    if(file_exists($path.$image))
    {
        header("Content-Type: image/jpeg");
        echo file_get_contents($path.$image); # image to display
    }
    else
    {
        echo 'image not found';
    }
?>

The link to the image should be something like this:

http://localhost/img.php?image=dot.jpg&campaign_id=23&user_code=md5_hash_here

But you can use .htaccess and mod_rewrite to create a link easier to read:

http://localhost/img/md5_hash/23/dot.jpg

Obviously there will be a different md5 hash for each user, so you may have to automate the process. But if you are not interested on checking specific user habits then you need only links to identify the newsletter:

http://localhost/img/23/dot.jpg

And so on...

Downsides about this method: if you have many access there will be a lot of write activity to the database and by consequence to the disk, so you could use a work queue (as beanstalkd or gearman) to perform background inserts, or write them to the memory engine …

cereal 1,524 Nearly a Senior Poster Featured Poster

Also, remove ExpiresDefault "access plus 2 months" which will try to cache everything and not only the mimes declared below in the list. And add ExpiresActive On at the top because it is required by ExpiresByType:

Note that this directive only has effect if ExpiresActive On has been specified

cereal 1,524 Nearly a Senior Poster Featured Poster

Press the button Reset in the back view of the router. Then to log in use Admin as user and leave blank the password field. For more information check the manual: ftp://ftp.dlink.com/Gateway/dir615_revC/Manual/dir615_revC_manual_300.pdf

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You're mixing mysql with mysqli which are two different libraries, so it cannot work, change this:

if (@mysqli_num_rows($result_check) == 1)//if Query is successfull 
{ // A match was made.
    $_SESSION = mysqli_fetch_array($result_check, MYSQLI_ASSOC);//Assign the result of this query to SESSION Global Variable
    header("Location: page.php");
}else
{         
    $msg_error= 'Either Your Account is inactive or Email address /Password is Incorrect';
}

To:

if (mysql_num_rows($result_check) == 1)//if Query is successfull 
{ // A match was made.
    $_SESSION = mysql_fetch_array($result_check, MYSQLI_ASSOC);//Assign the result of this query to SESSION Global Variable
    header("Location: page.php");
}else
{         
    $msg_error= 'Either Your Account is inactive or Email address /Password is Incorrect';
}

Or better, convert everything to mysqli. Also when developping remove @ from functions, since this suppress the errors and you cannot see where's the problem.