cereal 1,524 Nearly a Senior Poster Featured Poster

As diafol pointed, you are not doing the login in your curl request. Anyway I use this function, that make use of file_get_contents() and works pretty well:

<?php

function getlink($url)
{
    $version = '2.0.1';
    $format = 'xml';
    $login = 'username';
    $appkey = 'API_KEY';
    $bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;

    $response = file_get_contents($bitly, TRUE);

    if($response !== FALSE)
    {
        $xml = simplexml_load_string($response);
        $link = 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
        return $link;
    } else {
        return FALSE;
    }
}

echo getlink('http://www.website.tld');

?>

which is based on http://davidwalsh.name/bitly-php
bye!

diafol commented: nice +14
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Try to remove the underscore from the CSRF cookie name:

$config['csrf_cookie_name'] = 'csrfcookie';

From what I've read in the past, it seems that latests IE versions don't like it.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition to diafol suggestion, I think this can also be done at SQL level, but the_date should be converted to a datetime field in order to do comparisons, now I think it's a varchar. You need to use BETWEEN ... AND ... expression:

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between

For example:

create table booking (
    id int(9) not null auto_increment primary key,
    the_date datetime null,
    id_state int(9) not null
) engine=myisam default charset=utf8;

insert into booking (the_date,id_state) values('2012-11-08 09:30:00','4'), ('2012-11-08 10:00:00','5'), ('2012-11-10 12:30:00','4'), ('2012-11-09 10:00:00','5'), ('2012-11-12 11:30:00','4'), ('2012-11-14 11:15:00','5');

select * from booking where the_date not between '2012-11-08' and '2012-11-10' and the_date <= curdate();

+----+---------------------+----------+
| id | the_date            | id_state |
+----+---------------------+----------+
|  3 | 2012-11-10 12:30:00 |        4 |
|  5 | 2012-11-12 11:30:00 |        4 |
|  6 | 2012-11-14 11:15:00 |        5 |
+----+---------------------+----------+

The output will include the end date, so just extend the range at script of SQL level. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

We need more details: which applications and versions? what have you tried to do? is this a fresh install or it stopped working? do you get any errors when you try to perform the install action?

From terminal try:

sudo apt-get update
sudo apt-get upgrade

and then retry to install.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition you can use alternate stylesheets, which are available also from the browser tools:

<link href="/styles/default.css" rel="stylesheet" title="default style" />
<link href="/styles/dark.css" rel="alternate stylesheet" title="dark style" />
<link href="/styles/white.css" rel="alternate stylesheet" title="white style" />

http://www.w3.org/Style/Examples/007/alternatives.en.html

To update you can set a cookie to save the CSS to load when visiting the website, for example:

<?php

$style = false;
$array_styles = array('default','dark','white');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    if(isset($_POST['theme']))
    {
        $time = time()+(60*60*24*7); # a week from now
        $value = in_array($_POST['theme'],$array_styles) ? $value : 'default';

        setcookie("Theme", $value, $time, "/", "mywebsite.tld", false);
        $style = $value;
    }
}

if(isset($_COOKIE['Theme']))
{
    $style = in_array($_COOKIE['Theme'],$array_styles) ? $_COOKIE['Theme']:'default';
}

echo '
    <link rel="'.($style == 'default' || $style === false ? '':'alternate ').'stylesheet" href="/styles/default.css" />
    <link rel="'.($style == 'dark' ? '':'alternate ').'stylesheet" href="/styles/dark.css" title="dark style" />
    <link rel="'.($style == 'white' ? '':'alternate ').'stylesheet" href="/styles/white.css" title="white style" />
';
?>

I didn't tested the code but it should work. More info about setcookie(): http://php.net/manual/en/function.setcookie.php

cereal 1,524 Nearly a Senior Poster Featured Poster

It would be easier knowing how the main arrays are generated. If the source is a database this can be done in a previous step. And also, as LastMitch pointed, post also your code. Anyway, this is a test example, it outputs the new arrays without the collision:

<?php

$data1 = array(
        array(
        '7'=>'chelsea everton villa liverpool',
        '8'=>'everton villa liverpool manutd',
        '9'=>'villa liverpool manutd arsenal',
        '10'=>'liverpool manutd arsenal newcastle'
        ),
        array(
        '23'=>'milan inter juventus napoli',
        '24'=>'inter juventus napoli roma',
        '25'=>'juventus napoli roma udinese',
            ),
        array(
        '53'=>'madrid barcelona altetico getafe',
        '54'=>'barcelona altetico getafe betis',
        '55'=>'altetico getafe betis valencia',
    '8'=>'everton villa liverpool manutd',
        )
        );

$data2 = array(
        array(
        '3'=>'milan inter juventus napoli',
        '4'=>'inter juventus napoli roma',
        '5'=>'juventus napoli roma lazio',
        ),
        array(
        '23'=>'PSG barcelona altetico getafe',
        '24'=>'barcelona monaco getafe betis',
        '25'=>'monaco getafe betis valencia',
        ),
        array(
        '37'=>'swansea watford villa liverpool',
        '38'=>'watford villa liverpool manutd',
        '39'=>'villa liverpool manutd arsenal',
        '40'=>'liverpool manutd arsenal newcastle'
        ),
        array(
        '37'=>'santos flamengo saopaulo riverplate',
        '38'=>'flamengo saopaulo riverplate penarol',
    '8'=>'everton villa liverpool manutd',
        )
        );



$n = 0;
$matches = array();
$new_data1 = array();
$new_data2 = array();
$n1 = count($data1);
$n2 = count($data2);

for($x = 0; $x < $n1; $x++)
{
    # loop $data1 array
    foreach($data1[$x] as $k1 => $v1)
    {

        for($y = 0; $y < $n2; $y++)
        {

            # loop $data2 array
            foreach($data2[$y] as $k2 => $v2)
            {
                # check if values from first and second are the same
                if($v1 == $v2)
                {

                    # $hash variable is used to save sha1 outputs of the two matching
                    # …
LastMitch commented: Thank You! +6
cereal 1,524 Nearly a Senior Poster Featured Poster

Try this:

<?php

$arr = array( 
  array( 
    '7'=>'repsol kawasaki honda ktm', 
    '8'=>'kawasaki honda ktm bmw', 
    '9'=>'honda ktm bmw ducati', 
    '10'=>'ktm bmw ducati yamaha'
  ), 
  array( 
    '23'=>'lamborghi ferarri mercedes hyundai', 
    '24'=>'ferarri mercedes hyundai toyota',
    '25'=>'mercedes hyundai toyota nissan',
    '26'=>'hyundai toyota nissan renault'
  ), 
);

$z = array();
foreach($arr as $k1 => $v1)
{
    $i = 0;

    foreach($v1 as $k2 => $v2)
    {
        if($i == 0)
        {
            $z[$k1][$k2] = $v2;
        }
        else
        {
            $r = explode(' ',$v2);
            $z[$k1][$k2] = end($r); # use end() to get last element in array
        }
        $i++;
    }

}

print_r($z);
?>

It will output as requested:

Array
(
    [0] => Array
        (
            [7] => repsol kawasaki honda ktm
            [8] => bmw
            [9] => ducati
            [10] => yamaha
        )

    [1] => Array
        (
            [23] => lamborghi ferarri mercedes hyundai
            [24] => toyota
            [25] => nissan
            [26] => renault
        )

)

http://www.php.net/manual/en/function.end.php
bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You can perform a redirect to a "success.php" page or turn to an error page. You can do this with header():

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers)) # TRUE
{
    header('Location: success.php');
}
else                                        # FALSE
{
    header('Location: error.php');
}

http://php.net/manual/en/function.header.php

For better help post your code. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

On your Form your <input type> should be text not passowrd.

Just a small correction: type can also be password ( http://www.w3.org/TR/html5/the-input-element.html#attr-input-type & http://www.w3.org/TR/html401/interact/forms.html#input-control-types ), the only difference between text and password is the masquerading in the client side, while on the server side you get the same string. Bye.

LastMitch commented: Didn't know that! Nice to know! +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Check the manual: http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

~ is a delimiter, from the manual:

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~)

(.*?) it's a loop to match the contents of href attribute, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You can boot on recovery mode, you will get a root shell, from which you can use passwd command to assign a new password to the root account. You will not need the old one, from there you can change the other accounts passwords and regain access.

cereal 1,524 Nearly a Senior Poster Featured Poster

LastMitch I think it's CodeIgniter framework :)

@nico
Change lines 20 and 21 with:

 $username = $this->input->post('username');
 $password = this->input->post('password');

so each field will be sanitized and if it is empty or wrong will return FALSE: http://codeigniter.com/user_guide/libraries/input.html

bye!

LastMitch commented: I knew that but I wasn't sure! ;) +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Add:

extension=mysql.so

to php.ini or check if there is a mysql.ini file in /etc/php5/apache2/conf.d and place this directive there, then reload the server:

sudo service apache2 reload

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use a single query to do this and get directly the rows of the second query:

$sql = mysql_query("select * from servers, (select id as ids from servers where active = '1') as s where id = s.ids");

Then use the while loop as in my previous example to print/collect the result set:

while($row = mysql_fetch_array())
{
    echo $row['id'];
    # . . .
}
mmcdonald commented: true :D +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Try this:

$list = array();
while($ids = mysql_fetch_array($sql)){
    $list[] = $ids['id'];
}

print_r($list);

bye!

mmcdonald commented: good shout +1
cereal 1,524 Nearly a Senior Poster Featured Poster

Yes you can do that, I only suggest you to use arrays:

$data['home']['description'] = 'home descr..';
$data['home']['keywords'] = 'home,descr,..';
$data['home']['title'] = 'Home Title';

$data['gallery']['description'] = 'home descr..';
$data['gallery']['keywords'] = 'home,descr,..';
$data['gallery']['title'] = 'Home Title';

so, for example, if you have parameters in your URL you can use it to get the correct data:

http://www.mysite.tld/index.php?section=gallery

check if section is in $data and display:

include $path;
...
$section = $_GET['section'];
if(in_array($section,$data))
{
    echo $data[$section]['title'];
}
else
{
    echo $data['home']['title'];
}

bye!

diafol commented: genius is wasted! :( +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I think you can use Gearman, it allowes you to do parallel processing, you have to set a client to retrieve data and send it to a job server, this will call the workers registered for that particular task.

Here's a example in slow motion of the client script:

<?php

$a = range('a','z');

$gmclient = new GearmanClient();
$gmclient->addServer('127.0.0.1');

do
{
    $i = 1;
    foreach($a as $letter)
    {
        # serialize $letter if this is an array
        $gmclient->addTaskHighBackground("echo", $letter);
        $gmclient->runTasks();

        if(2%$i) sleep(2);
        $i++;
    }

    # kills this script after the loops ends if file exists
    if(file_exists(stop.txt))
    {
        break;
    }
}
while(true);

?>

and this is the worker:

<?php

$worker = new GearmanWorker();
$worker->addServer('127.0.0.1');
$worker->addFunction("echo", "task");

while ($worker->work())
{
    if ($worker->returnCode() != GEARMAN_SUCCESS)
    {
        echo "return_code: " . $worker->returnCode() . "\n";
        break;
    }
}

function task($job)
{
    $data = $job->workload(); # unserialize if you are receiving an array
    echo $data .' '. date('Y-m-d G:i:s')."\n";
}

?>

to start, open few terminals, in the first start the client and in the others the workers:

php client.php
php worker.php
...

You will see in the workers terminals the output of the above example: a simple output of letters and timings. A worker can call other workers to permform a secondary tasks, and these can be executed in background with different priorities. Check PHP manual to get install instructions:

http://php.net/manual/en/book.gearman.php

To start the gearman job server you can use this command:

gearmand -j 5 -v -l usage.log
mmcdonald commented: awesome, ill try this now thanks! +1
cereal 1,524 Nearly a Senior Poster Featured Poster

I think he is referring to the PHP graphic library, if so there is no direct relation between JQuery and GD. If you're using a debian based distro then use: sudo apt-get install php5-gd to install the library, but it should be already included in your PHP installation:

Since PHP 4.3 there is a bundled version of the GD lib. This bundled version has some additional features like alpha blending, and should be used in preference to the external library since its codebase is better maintained and more stable.

source: http://www.php.net/manual/en/image.requirements.php

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

Hello. The problem is in this post. First block of code, line 5 and line 9. I see a difference between normal view and raw view (on double click). In normal view line 5 appears like:

<Directory />

in raw:

<Directory ></Directory>

and the same happens on line 9. These are the screenshots:

normal view
raw view

I'm not sure if the enclosing tags where added here by daniweb scritps or by the author's post, but a part this, the problem is that the normal view is not displaying the same content. Also, apparently, I'm not able to reproduce the issue: posting the same code didn't create this difference.

Thank you for your attention.

Dani commented: Thanks for the catch +0
cereal 1,524 Nearly a Senior Poster Featured Poster

The only problem I see here is in the raw output of the default code block (double-click on the first block of code), I'm not sure if this is a daniweb bug or if it was already like this, maybe an IDE auto-correction. I'm referring to lines 5 and 9 where I see:

<Directory ></Directory>

and

<Directory /var/www></Directory>

change them with:

<Directory />
<Directory /var/www/>

and it should work. But anyway: the directory in which you have to place the files is /var/www not /usr/share/apache2/default-site. So move phpinfo.php to /var/www as stated in the configuration file.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you are using Apache web server then use an .htaccess file, with this directive:

order allow,deny
deny from all

put this inside upload directory.

cereal 1,524 Nearly a Senior Poster Featured Poster

@Garret85 to check if PHP is installed type php -v in the terminal, you will get the version. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe is the $md5Key, in your code:

$md5Key="44q9dn7WCUrLHgi8bPsdiBIlLi6WaHI0"; //MD5 key

but this doesn't seem a valid hash, for two reasons:

  • it's not lower case
  • there are invalid characters, an md5 hash is composed by hexadecimal numbers only, so: 0-9 a-f.

Now I'm wondering if this key is saved in the remote service and used to check data. If yes then it is probably giving an error.

cereal 1,524 Nearly a Senior Poster Featured Poster

Let's start from line 20:

if ($fld=='news_added') { $check = " where `inserted_date` = '$date' AND `news_added` = '$value' ";}

the problem here is that if this condition is false and the other two conditions (line 21 and 22) are true, $check variable will print only:

AND `code` = '$value' AND `id` = '$value'

without WHERE, this will give error on line 30, because the resulting query will be:

select * from `scrapes` AND `code` = '$value' AND `id` = '$value' limit 1

you should get an error at line 30 from die(mysql_error()). A part from this, if you want to update existing rows then you have to change the query on line 35 with an UPDATE statement.

cereal 1,524 Nearly a Senior Poster Featured Poster

Go to Settings » Accounts and Imports and click on Import mail and contacts. For more information you can follow this article: http://support.google.com/mail/bin/answer.py?hl=en&answer=117173

cereal 1,524 Nearly a Senior Poster Featured Poster

Line 52 you forgot ; at the end of the value: $ans = "Real Glo"; // Answer to image.

Djmann1013 commented: Thanks! It really helped! +2
cereal 1,524 Nearly a Senior Poster Featured Poster

You can use get_browser() function or $_SERVER['HTTP_USER_AGENT'] to read the user agent of the clients and if there is a match with Google bots you will not run the query, something like:

<?php

$browser = $_SERVER['HTTP_USER_AGENT'];

if(!preg_match('/Google[bot]/i',$browser))
{
    # insert query here
}
else
{
    echo 'bot';
}

?>

the else statement is optional. Here's the list of Google bots user-agents: https://developers.google.com/webmasters/control-crawl-index/docs/crawlers

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

Remove the () from the regex, seems to work for me:

<?php

function translate($content,$lang){
    $l = $lang;
    $pattern = array('en'=>'/\{\{.[^\}\}]*\|\|/','cy'=>'/\|\|.[^\{\{]*\}\}/'); # change this
    $brackets = array('en'=>'}}','cy'=>'{{');
    $content = preg_replace($pattern[$l],'',$content);
    $content = str_replace($brackets[$l],'',$content);
    return $content;
}

$content=<<<CONTENT
<p>{{Dyma destun (cy example) rand ||Here's some text en (example) rand}}</p>
CONTENT;

echo translate($content,'en');

echo "\n";

?>

or I'm missing the problem? o_o'

diafol commented: Spot on! Thanks again :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster

This happens also in javascript, I found this problem while working on a cart application. Check also these: http://stackoverflow.com/questions/3726721/php-math-precision & http://stackoverflow.com/questions/1458633/elegant-workaround-for-javascript-floating-point-number-problem

broj1 commented: Good information, thnx +5
cereal 1,524 Nearly a Senior Poster Featured Poster

Check this project: http://code.google.com/p/red5-flex-streamer/
it's done with java, flash and php.

diafol commented: nice +0
karthik_ppts commented: Thanks for your valuable link +7
cereal 1,524 Nearly a Senior Poster Featured Poster

Check the length of the password field in the database, you wrote:

my password is = "y"
the one that i log in =d41d8cd98f00b204e9800998ecf8427e
the one in db = 415290769594460e2e48

now:

echo md5('y'); #outputs 415290769594460e2e485922904f345d

which is the same of the db version, but it seems that in your database the field is accepting only 20 chars, so change varchar(20) to varchar(32) which is the standard output for md5 function. And update the field with the new value, since the previous is truncated.

The hash that you get from the form, is generated by a boolean false:

md5(false); #outputs d41d8cd98f00b204e9800998ecf8427e

so check with a print_r($_POST); what you receive from the form. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

@LastMitch
if you install an extension like stylish in your browser you can add a simple rule to hide that bar:

#toolbar { display:none; }

besides I like that bar and I use it! bye! :D

cereal 1,524 Nearly a Senior Poster Featured Poster

If the server is under linux you can use dmidecode for the motherboard serial:

sudo dmidecode --type 2 |grep -i serial

For the harddisk use hdparm:

sudo hdparm -I /dev/sda | grep -i serial

this will check for the serial of the master hd, for slaves you have to check for sdb, sdc... in any case, with both commands, you need to provide a password or you have to add the Apache user to the admin group which, for security reasons, it is never a great idea.

cereal 1,524 Nearly a Senior Poster Featured Poster

Change it like this:

<?php
class myClass
{
    public $myVar="this is demo";

    public function myTextdemo()
    {
        return $this->myVar; # the problem was here
    }
}

$obj = new myClass();
echo $obj->myVar; # and here you wrote $obj->$myVar with an extra $
?>

use return to output data from a function not echo and use $this inside the class functions, otherwise the declared property will not be considered and you will get an error like Undefined variable...

http://www.php.net/manual/en/language.oop5.properties.php

bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Change this part:

$imgdata[0] = $width;
$imgdata[1] = $height;

with this:

$width = $imgdata[0];
$height = $imgdata[1];

bye!

Khav commented: The awesome helper of all time~Khav +1
cereal 1,524 Nearly a Senior Poster Featured Poster

If these connections are related to httpd service then check the access.log and the error.log of your web server, if you are using Apache then go to /var/log/apache2/. From there you can read what kind of requests are done and if there is something strange.

Use nslookup to check the source IP, it could be a spider, if that is the problem then you can use the robots.txt file to stop connections.

Otherwise in order to block an IP you have to add a rule to the server firewall, you can use iptables or the ufw interface which is the same but easier. Check the documentation and be careful to not block ssh access to your IP:

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, try also to set CURLOPT_FORBID_REUSE: http://php.net/manual/en/function.curl-setopt.php
For example if you have a group of files to download from the same source, add this option only in the last loop, so curl can use the previous connection and your script should execute faster.
Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

The md5sum is part of the coreutils which can be found & downloaded from this link: http://www.gnu.org/software/coreutils/

cereal 1,524 Nearly a Senior Poster Featured Poster

That identifier is not present in the json file, anyway, just add a if statement inside the loop:

<pre>
<?php
$a = json_decode(file_get_contents('http://www.ace-spades.com/serverlist.json'),true);
$n = count($a);

for($i=0; $i < $n; $i++)
{
    if($a[$i]['identifier'] == 'aos://2252626508:32887')
    {
        echo 'identifier: ' . $a[$i]['identifier'] .' count: '. $a[$i]['count'] . "\n";
    }
}
?>
</pre>

if you want to check a range of identifiers then add an array and change the if statement:

$array = array(
    'aos://2252626508:32887',
    'aos://1379434439:36887',
    'aos://3819391052:32887'
);

if(in_array($a[$i]['identifier'],$array))

bye!

Djmann1013 commented: Thank you. This works! I am glad you helped me. Thanks! +1
cereal 1,524 Nearly a Senior Poster Featured Poster

It depends on the storage engine, field types, encoding. Check this link: http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

In a distributed system you can do that but not in a single laptop, at least looking at the specs it is hardly possible:

look like a fool :D

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm experiencing the same problem, I noticed that I cannot scroll over ~210 lines (sometimes 200, sometimes 220), the scrollbar stops but the cursor can go further. I can reproduce the issue just by pasting the result of this script:

<?php
    $a = range(0,300);
    $n = count($a);
    $result = null;

    for($i=0;$i<$n;$i++)
    {
        $result .= $i . "\n";
    }
    file_put_contents('this.log',$result);
?>

This problem occurs to me in Google Chrome, Opera and Firefox. I'm using Ubuntu 12.04. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You can do it like this:

<?php

function avg($limit = 9)
{
    $array = array();
    $result = array();
    for($i = 0; $i <= $limit; $i++) {

        $r = rand(1,100);
        if(in_array($r,$array))
        {
            #add another loop
            $i--;
        }
        else
        {
            $array[] = $r;
        }
    }

    $c = count($array);
    $s = array_sum($array);

    $avg = round($s/$c);

    $result['avg'] = $avg;
    for($i = 0; $i < $c; $i++) {
        $result['numbers'][] = ($avg > $array[$i]) ? $array[$i].' ':'';
    }

    $result['numbers'] = array_filter($result['numbers']);
    return $result;
}

print_r(avg());

?>

This function removes duplicates from the array generated by rand() and performs an additional loop everytime it finds one. An example of output will be:

Array
(
    [avg] => 56
    [numbers] => Array
        (
            [0] => 54 
            [3] => 48 
            [5] => 6 
            [7] => 25 
            [8] => 46 
        )

)

Hope is useful.

cereal 1,524 Nearly a Senior Poster Featured Poster

Check this project: http://sourceforge.net/projects/opensourcepos/
And turn-off CAPS when you write in a forum, it's equal to yelling. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Create a file with below code an upload it in your server:

<pre>
<?php

    $path = $_SERVER['DOCUMENT_ROOT'] . "/root/";

    echo file_exists($path) ? 'directory exists ':'directory not found ';
    echo is_dir($path) ? 'it is a directory ':'it is not a directory ';
    echo is_writable($path) ? 'is writable ':'is not writable change permissions ';

?>
</pre>

This will tell you if there is a resource named root, if this is a file or a directory and if this is writable. Of course if something is wrong, for example a path issue o a slash you will get negative outputs. If you have doubts, paste results here so we can check it. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, except for line 29 which is extra, that will give you an error, just remove it and check if the script is working, if not, then you have to change permissions, chmod 755 maybe enough.

cereal 1,524 Nearly a Senior Poster Featured Poster

Set a $path variable:

$path = $_SERVER['DOCUMENT_ROOT'] . "root/";

Line 25:

if (file_exists($path . $_FILES["file"]["name"]))

Lines 31/32:

move_uploaded_file($_FILES["file"]["tmp_name"], $path . $_FILES["file"]["name"]);

In general: output $_SERVER['DOCUMENT_ROOT'] so you know if there is a trailing slash or not, if not then change $path variable to:

$path = $_SERVER['DOCUMENT_ROOT'] . "/root/";

bye!

jamied_uk commented: is this correct? <form enctype="multipart/form-data" action="upload.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> <?php $path = $_SERVER['DOCUMENT_R +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Set an absolute path in the second argument of move_uploaded_files(), at the moment this is relative to the script. The same applies to file_exists(). You can use $_SERVER['DOCUMENT_ROOT']. Also use getimagesize() to ensure that uploaded file is really an image, at least do this check, the mime it self is not reliable, since it can be spoofed..

jamied_uk commented: what line number do i need to edit and what is the edit i should make and i will try it right now :d thanks for your reply +0