cereal 1,524 Nearly a Senior Poster Featured Poster

In addition to previous notes, the direction of the text depends on the HTML dir attribute, an example of multilanguage page:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>sample arabic language</title>
</head>
<body>
    <p lang="ar" dir="rtl">مرحبا</p>
    <p>hello</p>
</body>
</html>

If your page is not mixed and you have only Arabic, then change it to:

<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="utf-8">
    <title>sample arabic language</title>
</head>
<body>
    <p>مرحبا</p>
</body>
</html>

The rtl value stands for right-to-left. I don't know Wordpress, plus I don't know if you're using an uri segment to define the language in use, but it should be easy to set lang and dir attributes on the fly.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Use reload:

sudo service apache reload

in practice Apache will perform a graceful restart, it is the same of running:

apachectl -k graceful

it means that will finish to serve the current requests before restarting.
For more information and options check: http://httpd.apache.org/docs/2.2/en/stopping.html

cereal 1,524 Nearly a Senior Poster Featured Poster

The difference is that if bar is null isset() will return FALSE, while array_key_exists() will still return TRUE:

$foo['bar'] = NULL;

echo isset($foo['bar']) ? 'true':'false';
echo array_key_exists('bar',$foo) ? 'true':'false';

So it depends on your intentions.

diafol commented: never knew that +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Line 32:

<option value="<?php echo $ho('interior_house_id');?>"><?php echo $ho['interior_house_desc'];?></option>

Change $ho('interior_house_id') to $ho['interior_house_id'] and it should work. Also I suggest you to use $this->input->post() instead of $_POST since it sanitized by the framework (if $config['global_xss_filtering'] = TRUE;). Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster
This is for Laravel 3.*
Hello,

With this snippet I'm providing a simple way to automatically filter Input::get() and Input::old(). To achieve this result we need to make few changes:

  • extend Input and Redirect classes by creating new files in application/libraries/, the files are: input.php and redirect.php;
  • comment the aliases of these classes in application/config/application.php file, otherwise the application will ignore the extended libraries.

The extended Input class overwrites Input::query() so it can use the new method Input::sanitize(), which is where you can place your filters, in this example I'm using filter_var_array():

public static function sanitize($array)
{
    $result = filter_var_array($array, FILTER_SANITIZE_STRING);
    return $result === false || is_null($result) === true ? array() : $result;
}

But it can be rewritten as you like, this method is just a container for your prefered approach, it can be an implementation of CodeIgniter xss_clean() method, or you can simply use strip_tags(). Just make sure to return an array of keys and values.

Below there is a version working with the HTMLPurifier library, in this case I'm using the porting published in the bundles archive. Once installed, you can change the above method with:

/**
 * Filter the query string array
 *
 * <code>
 *      // Return an empty array if data is removed
 *      $array = Input::sanitize(array('msg' => 'hello'));
 * </code>
 *
 * @param  array   $array
 * @param  array   $input
 * @return array
 */

public static function sanitize($array, $input = array())
{
    $purifier = IoC::resolve('HTMLPurifier');
    $array = filter_var_array($array, …
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
take a look at Google Custom Search API: https://developers.google.com/custom-search/v1/overview

Once you get results you can scan the links in search of microformats or metadata. To do that you will need a microformat parser or something like get_meta_tags() for metadata. Then, if you want more results or compare data, you could add a callback to check the contact page and try to parse the <address> tag or search for emails and phone numbers.. it'a a bit tricky.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use a recursive function which checks if the value of the pair $key => $value is an array, in this case it loops again, an example:

<?php

    $food = array(
        'Healthy'   => array('Salad','Rice','Vegtables' => array('Tomatto','Onion')),
        'UnHealthy' => array('pasta', 'Vegetables' =>array('potatto', 'Corn')));

    function recursive_loop($array)
    {
        foreach($array as $key => $value)
        {
            if(is_array($value))
            {
                recursive_loop($value);
            }
            else
            {
                echo $value . PHP_EOL;
            }
        }
    }

    echo recursive_loop($food);
cereal 1,524 Nearly a Senior Poster Featured Poster

You could move CodeIgniter to a subdirectory:

/index.html
/backend/index.php
/backend/system/
/backend/application/

Create an .htaccess file inside backend and change the rewrite rule to match the directory:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /backend/index.php/$1 [L]

A part from this solution, keep in mind that you can create simple Controllers and Views to run the frontend.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, if I'm not wrong you cannot replicate many Masters to one single Slave in MySQL, but you should check MySQL documentation and switch between versions to check if there are any changes: http://dev.mysql.com/doc/refman/5.1/en/replication.html

Note: if you are trying to apply replication in relation to your previous thread on PHP forum about searches on multiple databases, I suggested you about federated tables because it can be used to connect to multiple servers... then you could use a local cache system to temporary save part of the data queried by the clients...

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Let say the databases are on ServerB and ServerC and the main website with the search function is on ServerA, if the servers are in the same network you can use bind-address directive:

bind-address = 192.168.0.100 # local network IP address

Otherwise you have to comment this directive #bind-address and setup a firewall rule to allow connections to MySQL only from ServerA IP address. Once this is done you can directly access remote databases or you can choose to use federated tables: http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html which let you access remote databases by using your local server.

Consider also to setup SSL connections between the servers: http://dev.mysql.com/doc/refman/5.0/en/ssl-connections.html otherwise the data can be captured very easily.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

If you don't have a profile i.e. a specific and allowed access to edit your own submitted data, you can only contact the host and ask the removal. Differently, your action will be considered a cracking attempt.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes you can, just change the first SELECT statement with a DELETE as this:

DELETE FROM wp_options, (SELECT SUBSTR(option_name,20) AS string FROM wp_options WHERE STRCMP(option_name,'_transient_timeout_') = 1 AND option_value < unix_timestamp()) AS sub WHERE option_name IN (CONCAT('_transient_',sub.string),CONCAT('_transient_timeout_',sub.string));

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you post the results of:

show create table tbl_user_reg\G
show create table tbl_course_offred\G

It will help to understand the relations between the two tables.
If I understood your request in tbl_course_offred you have a column skills which is varchar and saves multiple values as php,css,html and you want to be able to search one of those?

If yes, you can use a fulltext search query: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

In order to work you have to add a fulltext index to the table, which needs to be MyISAM (it works with InnoDB only from MySQL 5.6 and above). But there are some limits:

1) words less or equal to 3 characters are not considered, unless you edit/add ft_min_word_len in the config file of the MySQL server (/etc/mysql/my.cnf), otherwise if you want to search php you get an empty result set. After the edit you have to reload/restart MySQL server and rebuild the fulltext index by running repeair table table_name;
2) if the searched word represents more then 50% of the index the query will return an empty set;
3) you need more then 3 rows to get results;
4) it doesn't work across multiple tables, but you can perform a subquery to provide a value to search in the other table.

An usage example: http://dev.mysql.com/doc/refman/5.0/en//fulltext-natural-language.html

In CodeIgniter, as the previous thread of yours, you have to use the query method, an example:

$this->db->query("SELECT * FROM tbl_course_offred MATCH(skills) AGAINST('php')");
cereal 1,524 Nearly a Senior Poster Featured Poster

To display the datepicker you have to set an id to the input field, you can do it by passing an array of attributes:

datefield = forms.TextInput(attrs={'id': 'datepicker', 'placeholder': 'Click to select'})
datefield.render('field_name', 'Pick up a Date')

Read: https://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs

cereal 1,524 Nearly a Senior Poster Featured Poster

Just to be clear, use: SUBSTR(option_name,20) instead of SUBSTR(option_name,-3,3)

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, start to count from the beginning, for example for:

_transient_timeout_gad_cache_5_776fa175e6cc472b8c7

we start to count up to _transient_timeout_ which is 19 and use SUBSTR to take the rest:

select substr('_transient_timeout_gad_cache_5_776fa175e6cc472b8c7',20) as string;
+---------------------------------+
| string                          |
+---------------------------------+
| gad_cache_5_776fa175e6cc472b8c7 |
+---------------------------------+
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, try:

SELECT * FROM wp_options AS main, (SELECT SUBSTR(option_name,-3,3) AS string FROM wp_options WHERE STRCMP(option_name,'_transient_timeout_') = 1 AND option_value < unix_timestamp()) AS sub WHERE option_name IN (CONCAT('_transient_',sub.string),CONCAT('_transient_timeout_',sub.string));

If it works then just convert the main query to delete. In my example I'm using:

SUBSTR(option_name,-3,3)

to extract the last 3 characters which are used as sub.string in the CONCAT statements, but you can rearrange it as you prefer, depending on the length of your unique values... for more info check:

Anyway, it would be easier to store a third column as timestamp, that way you could avoid the second row:

CREATE TABLE `wp_options` (
  `option_name` varchar(255) DEFAULT NULL,
  `option_value` varchar(255) DEFAULT NULL,
  `option_timeout` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=utf8
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

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

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

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

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

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.

cereal 1,524 Nearly a Senior Poster Featured Poster

Read this: https://help.ubuntu.com/community/Grub2
Grub2 is a bit complex. At the end of the linked page there are some links that explain how to edit the config files.

cereal 1,524 Nearly a Senior Poster Featured Poster

Something like this will work:

<?php
    $path = '/vault/';
    $f = $_GET['file'];
    $f = pathinfo($f);

    if(file_exists($f['basename']) && strtolower($f['extension']) == 'pdf')
    {
        $file = file_get_contents($path.$f['basename']);
        header("Content-Type: application/pdf");
        echo $file;
    }
?>

Just create a directory pdf, put a file index.php as above and build links like this:

http://localhost/pdf/?file=thecbook.pdf

The access to the direct path containing the files, then can be limited by .htaccess:

Order deny,allow
Deny from all

So, no one can directly access to:

http://localhost/vault/thecbook.pdf

Anyway, to make the resources available only to registered users you have to add sessions, so the above script becomes something like:

<?php

    session_start();

    if(isset($_SESSION['logged']) && $_SESSION['logged'] === true)
    {
        $path = '/pdf/vault/';
        $f = $_GET['file'];
        $f = pathinfo($f);

        if(file_exists($f['basename']) && strtolower($f['extension']) == 'pdf')
        {
            $file = file_get_contents($path.$f['basename']);
            header("Content-Type: application/pdf");
            echo $file;
        }
    }

    else
    {
        header('HTTP/1.0 401 Unauthorized');
        echo '401 Unauthorized Access! Please login first.';
    }

?>

Hope is useful, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Try mysql-server and mysql-client, these are metapackages that redirect to the latest version available in repositories. If it doesn't match try dpkg -l mysql-* it will list all the packages related to mysql. And to remove them all, you can run dpkg -r mysql-*

EDIT
You can use --purge to remove also the config files: dpkg --purge mysql-*

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition to previous suggestions, you can mitigate the problem by adding an .htaccess file to the directory in which are hosted the images and specify to treat them with the default handler for static files:

SetHandler default-handler

If you upload a php file to this directory and try to open it, this will not be executed but downloaded as a simple file. Another measure is to add this line to the .htaccess file:

php_flag engine off
cereal 1,524 Nearly a Senior Poster Featured Poster

This is my little list of test tools:

Consider also to use BackTrack or Samurai, a live distro focused only in web sites testings. Bye!

broj1 commented: This is very useful info, thnx. +8
cereal 1,524 Nearly a Senior Poster Featured Poster

While waiting for more appropriate support, try to load randomize. This seems to work fine for me:

Program Test;

var
  num:longint;

begin
  randomize;
  num:=random(1000000);
  write(num, '');
  writeln;
end.

Source: http://www.freepascal.org/docs-html/rtl/system/randomize.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Not completely, they posted an update few days later: http://www.php.net/archive/2012.php#id2012-05-06-1

The rewrite rule to test is this:

RewriteCond %{QUERY_STRING} ^[^=]*$
RewriteCond %{QUERY_STRING} %2d|\- [NC]
RewriteRule .? - [F,L]

basically try something like this:

If you don't get the source of the page then it's reasonably safe. But it is always better to upgrade at least to 5.3.13 or 5.4.3 as suggested by PHP.net advisory. You can find more information and few patch suggestions here:

http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/

Or search for CVE-2012-2311 on google. Anyway, remember this is related only to mod_cgi.

LastMitch commented: Thanks for Sharing! +0
cereal 1,524 Nearly a Senior Poster Featured Poster

You can do that, but first you need to download the files from repositories and make sure you are satisfying all the dependencies, once you have all the files you can use dpkg for example:

dpkg -i package_name.deb

For more info type man dpkg or dpkg --help.

cereal 1,524 Nearly a Senior Poster Featured Poster

Use AND OR not comma. The logical operators available for MySQL are these: http://dev.mysql.com/doc/refman/5.0/en/logical-operators.html

So your query becomes:

$query = "SELECT * FROM customers WHERE firstname = '$firstname' AND lastname = '$lastname'";
cereal 1,524 Nearly a Senior Poster Featured Poster

Change line 5 and 6:

$query = "SELECT * FROM customers WHERE firstname = '$firstname'";
$result = mysql_query($query);
cereal 1,524 Nearly a Senior Poster Featured Poster

Add CURLOPT_RETURNTRANSFER:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

And try simplexml_load_string here:

$xml = simplexml_load_file(utf8_encode($xml_url), 'SimpleXMLElement', LIBXML_NOCDATA);

bye!

mehnihma commented: Thanks, overlooked your post +2
cereal 1,524 Nearly a Senior Poster Featured Poster

@ska

check this: http://sourceforge.net/projects/php-proxy/

But if you set a proxy in your website to redirect youtube, you and the other users should also connect to it through a proxy or a VPN, so that authorities cannot trace your activity.

Read this as reference: http://en.rsf.org/fighting-cyber-censorship-12-09-2012,43366.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to change quotes with backticks in the field names of the INSERT statement, as here:

$req = "INSERT INTO $tablename(`$tablecol`) VALUES ('$tablecoldat')";

Also, to catch an error use mysql_error() at least in this stage:

 mysql_query($req, $connection) or die(mysql_error());
cereal 1,524 Nearly a Senior Poster Featured Poster

Try to add:

Memcached::OPT_TCP_NODELAY => true

It seems to work for me.

cereal 1,524 Nearly a Senior Poster Featured Poster

You should get the file list inside the directory to delete, loop ftp_delete() for each and ftp_rmdir() for each subdirectory, but they need to be empty as the main directory to delete. So it's a bit tricky, the functions you need to use are:

ftp_delete()
ftp_nlist()
ftp_rmdir()

http://php.net/manual/en/ref.ftp.php

You can also use functions like opendir(), unlink() and rmdir():

unlink('ftp://user:password@ftp_server');

but in the case of rmdir and ftp_rmdir the directory needs to be always empty and you need permissions, so in some occasions you'll need to use chmod() or ftp_chmod() since the ftp user is different from the server user, usually www-data.

In Addition
If you have to do a lot of this activity it could be better to place a script in the remote server, use cron to make it wait instructions and from local send a simple file or $_POST with the name of the directory to delete, you can use ftp_* or even curl. Just make sure that these ftp accounts are jailed otherwise it becomes dangerous.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use GeoIP library, for example:

$countrycode = geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
$loc = '/default/contents';
switch($countrycode)
{
    case 'FR':
        $loc = '/fr/contents';
    break;
    case 'IT':
        $loc = '/it/contents';
    break;
    case 'US':
        $loc = '/us/contents';
    break;
}

header('Location: '.$loc);

at that point you can also place a cookie to switch automatically each time the user comes back, but in order to use it you have to install the library:

This can be done with PECL or by command line, in debian/ubuntu type:

sudo apt-get install php5-geoip

Note, some of the functions as geoip_region_* will not work if you don't load the correct database, some of them are only available by payment, by default you get the Country database both IPV4 and IPV6, there is also the City db available for free:

In case you want to use it: download it, use gunzip to decompress the file gunzip GeoLiteCity.dat.gz and place it inside /usr/share/GeoIP/

EDIT
As side note, this can work also with other free GeoIP databases, but I didn't tested.

Hope is useful, bye.

blocblue commented: Very helpful resource +9
cereal 1,524 Nearly a Senior Poster Featured Poster

You can use cryptsetup: http://code.google.com/p/cryptsetup/
Here there is a tutorial for external drives:

https://help.ubuntu.com/community/EncryptedFilesystemsOnRemovableStorage

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,
when I try to enter to the PHP forum (but also in the others under Web Development section) I get redirected to a malformed url:

http://www.daniweb.com-development/php/17

I tried also with curl:

curl --head http://www.daniweb.com/web-development/php/17
HTTP/1.1 301 Moved Permanently
Date: Tue, 18 Dec 2012 15:31:11 GMT
Server: Apache/2.2
Location: http://www.daniweb.com-development/php/17
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

same response, bye!

p.s. the same is happening also under Hardware & Software.

cereal 1,524 Nearly a Senior Poster Featured Poster

The model is fine. In your /application/config/config.php set:

$config['log_threshold'] = 4;

then reload the page and check the generated log inside /application/logs/ that should help you to find the problem, note that logs directory needs write permissions.