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

You can save the resized file into PNG format, this will help to preserve quality. The length of the file will be higher than a JPG equivalent, but you can use some tools as optipng to compress the file without loosing quality. Or use JPG format also for the resized file and set quality over ~80%, this value usually returns a good looking file without artifacts.

Read this document, there you can find a lot of information about this topic: http://www.imagemagick.org/Usage/resize/

cereal 1,524 Nearly a Senior Poster Featured Poster

Most of the applications are installed under /usr directory, but you can also install software inside the bin directory of your profile and make the application available only to you, if you are searching for the config files, most of them can be found under /etc directory, anyway check these documents for more information:

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

cereal 1,524 Nearly a Senior Poster Featured Poster

If you check the comments at the end of the page, of the posted link, you will find some perl scripts to do such calculations ;)

cereal 1,524 Nearly a Senior Poster Featured Poster

I've already replied to this here: http://www.daniweb.com/web-development/php/threads/429083/searching-for-specific-text-on-a-page#post1837188

Please don't open more than one thread for the same question, if I cannot reply quickly someone else will do it..

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

Sorry, I made an example based on the json string posted above:

$linkcontents = '{"count": 5, "map": "(Server Map)", "uptime": 1436.2805321216583, "cumulative_uptime": 69137.85308456421, "name": "(server name)", "max": 12, "country": "(contry)", "identifier": "(server IP)", "game_mode": "(game mode)", "useless_ping": 99}';

sorry for that ;p I just forgot to be more specific, if you use count() you see that you get 153 arrays, you have to loop them in order to get what you want, for example:

<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++)
{
    echo 'identifier: ' . $a[$i]['identifier'] .' count: '. $a[$i]['count'] . "\n";
}
?>
</pre>
cereal 1,524 Nearly a Senior Poster Featured Poster

If you use json_decode() you can treat the input as an array:

$d = json_decode($linkcontents,true);
print_r($d);

that outputs:

Array
(
    [count] => 5
    [map] => (Server Map)
    [uptime] => 1436.2805321217
    [cumulative_uptime] => 69137.853084564
    [name] => (server name)
    [max] => 12
    [country] => (contry)
    [identifier] => (server IP)
    [game_mode] => (game mode)
    [useless_ping] => 99
)

and then you can simply: echo $d['count'];

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

Just replace $blacklist variable at line 23 of my example, if you want to use a csv/txt file where you store the bad words in this format:

hello, world, bad, word

then use:

$blacklist = array_map('trim',explode(',',file_get_contents('blacklist.txt')));

and you are finished. If you want to use json, instead, an example of the file contents will be:

["hello"," world"," bad"," word"]

and the $blacklist to use:

$blacklist = array_map('trim',json_decode(file_get_contents('blacklist.json')));

I hope it is clear enough.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can also try this solution:

<?php

function badword($word,$blacklist)
{
    if(in_array($word,$blacklist))
    {
        $w = substr($word,0,1);
        $len = strlen($word)-1;
        for($i=0;$i<$len;$i++)
        {
            $w .= '*';
        }
    }

    else
    {
        $w = $word;
    }

    return $w;
}

$blacklist = array('hello','world','bad','word');
$word = 'world';

echo badword($word,$blacklist); # output: w****

?>

$blacklist can be loaded from a database or from a text file if you use unserialize() or json_decode() The important is that you serve the black list as array. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

At line 9 I see this string:

$sql = "SELECT * FROM $dbase";

so you have a table with the same name of the database? I ask this because it seems your script expects a true condition from $result variable in the IF statement at line 13, so I suggest you to change line 11 with this:

$result = mysql_query($sql) or die(mysql_error());

and check if you get an error or false.

cereal 1,524 Nearly a Senior Poster Featured Poster

What kind of error you get?

cereal 1,524 Nearly a Senior Poster Featured Poster

I used VLC version 1.0.6 for Ubuntu 10.04

You should update your VLC. From VideoLan website: http://www.videolan.org/vlc/download-ubuntu.html

VLC version 1.0.6 in Ubuntu 10.04 is severely out-of-date. We recommend you install VLC 1.1.x manually.

bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you run explain table_name in your mysql client and paste the output together with an example of data maybe we can give you a hand. And also paste the query.

cereal 1,524 Nearly a Senior Poster Featured Poster

Besides why don't you use auto_increment? With that you don't even need to use unique key:

u_id int(10) not null auto_increment primary key
cereal 1,524 Nearly a Senior Poster Featured Poster

@diafol yours is good as is more complete than mine.. and I see I also forgot to sort.. o_o' 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

This can happen also if you send an empty string twice. Post your code.

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm afraid you cannot do that in the same script because the shebang needs to be in the first line, but you can separate them:

#!/bin/bash
a=$1
echo "hello $a from bash "
./script.php $a

and inside script.php

#!/usr/bin/php
<?php
$a = $argv;
echo "and hello $a[1] from php\n";
?>

in order to work script.php needs to be executive, otherwise just change the first script to php script.php.

At the end just run ./test gurusubramaniam and you will get:

hello gurusubramaniam from bash 
and hello gurusubramaniam from php

As alternative you can rearrange the bash script to be included in the PHP one:

#!/usr/bin/php
<?php
$a = $argv;
system('echo "hello '.$a[1].' from bash"');
echo "hello $a[1] from php\n";
?>

bye!

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

Add the command path to the crontab file or to the script, as I showed in my previous post and it will be executed.

cereal 1,524 Nearly a Senior Poster Featured Poster

The execution is automatic, you need to write also the command path. for example:

30 * * * * /usr/bin/php /srv/cron/mail.php

Otherwise add #!/usr/bin/php at the top of your script and make the file executable:

#!/usr/bin/php
<?php
    // . . .
    echo 'example';
?>

In command line use chmod: chmod +x mail.php
And in your crontab you can write:

30 * * * * /srv/cron/mail.php

At specific time the server will just run the script. Then you can go to /var/log to check crontab executions and you can also add error_log() to write a specific log about the excution of the functions in your script: http://php.net/manual/en/function.error-log.php

It this what you were asking for? Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

From from the manual:

By default vsftpd is configured to authenticate system users and allow them to download files

so if you log with garrett user the directory will be located in /home/garrett/, the configuration for the anonymous account is different, here the link to the manual with some basic information for config:

https://help.ubuntu.com/12.04/serverguide/ftp-server.html

bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

As workaround you can use an iframe to display the pdf and place the history.back link in the page, something like:

<html>
<head><title>go back</title></head>
<body>
    <p><a href="javascript:history.go(-1)">prev</a></p>
    <iframe width="900px" height="600px" frameborder="0" src="view.html" />
</body>
</html>

and in the view.html you place an object tag or a plugin as suggested by pritaeas:

<object width="850px" height="550px" type="application/pdf" data="/pdf/pdf_to_display.pdf"></object>
EDIT

well, I did a test.. you don't even need the iframe, just use:

<html>
<head><title>go back</title></head>
<body>
    <p><a href="javascript:history.go(-1)">prev</a></p>
    <object width="850px" height="550px" type="application/pdf" data="/pdf/pdf_to_display.pdf"></object>
</body>
</html>

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you post your updated code or upload it to your previous link?
In my test this is working, so maybe something went wrong.. you can also try to put a log inside the if statement to see if jquery it's executed:

console.log('hello!');

then just open the Javascript Console of your browser and run the script, through that you will also see what kind of error happens. Consider also, that the alternative method I posted searches for wrong id #result instead of #results as in your code.. my mistake.

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

Set an id in your form, in this example is myform:

<form action="" method="post" id="myform">

And change your jquery with this:

<script type="text/javascript">
$(document).ready(function(){

    $('#myform').submit(function(e) {
        // prevent reload of page
        e.preventDefault();

        if($('#thezip').length > 0) {
            // ajax call
            $.ajax({
                type: "POST",
                url: "search.php",
                data: $('#myform').serialize(),
                timeout: 30000, // 30 seconds
                cache: false,
                beforeSend: function(html) { // this happens before actual call
                    $("#results").html(''); 
                    $("#searchresults").show();
                    $(".word").html(searchString);
                },
                error: function(){
                    $("#results").hide().html('server not responding');
                },
                success: function(msg){ // this happens after we get results
                    $("#results").html(msg);
                }
            });

            // alternative method
            // $.post('search.php',$('#myform').serialize(),function(data) {$("#result").html(data)});
        }

        else
        {
            return false;
        }
    }); 
});
</script>

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

Yes, you can also enable a specific IP or a range:

sudo ufw allow from 192.168.0.1 to tcp port 443

Anyway, the link I posted above gives you all the information you need about UFW.

cereal 1,524 Nearly a Senior Poster Featured Poster

@jamied_uk

please reply by using the appropriate box, the Vote & Comment is not for questions, for this same reason I cannot read your reply because is truncated.

cereal 1,524 Nearly a Senior Poster Featured Poster

Basically run:

sudo ufw default deny
sudo ufw enable
sudo ufw allow 443/tcp
sudo ufw allow 4444/tcp

and also udp if you need to enable that too. You can list all rules by using:

sudo ufw status

You can read more by using man ufw or reading this document: https://help.ubuntu.com/community/UFW

cereal 1,524 Nearly a Senior Poster Featured Poster
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
cereal 1,524 Nearly a Senior Poster Featured Poster

Remove the trailing slash:

suPHP_ConfigPath /home/u471282391/public_html

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

I think the problem is in the second query, since zip is in both tables you should get an error like Column 'zip' in field list is ambiguous so try to add or die(mysql_error()) to check if this error happens, or just change the query to:

$query = "SELECT name, address, city, state, locations.zip, phone, lat, lon
FROM dealerships
INNER JOIN locations
ON dealerships.zip = locations.zip";

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, by using mkdir, you can use man command to get more information:

man mkdir

or in general search for a list of basic commands, like this one: http://code.google.com/edu/tools101/linux/basics.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Change this:

$query = mysql_query($sql);

with:

$query = mysql_query($sql) or die(mysql_error());

and check what you get. Also the session of the banned user should be destroyed.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you paste the code are you using? Have you tried to run the gearman job server?
You need to write something like:

gearmand -j 5 -v -l usage.log

you can also increase verbosity by adding up to five v -vvvvv. Besides, gearman suites better on linux, if you need to use Windows than give a try to RabbitMQ.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, here you can find more information: http://php.net/manual/en/language.types.array.php

cereal 1,524 Nearly a Senior Poster Featured Poster

I cannot help you much on this, I've seen this problem when using two different versions of PHP on the same box, but in linux is simple to solve: just change the path before using phpize... in windows, since you are placing the dll, try the other versions of php_printer.dll http://downloads.php.net/pierre/ otherwise, I think, you have to compile the dll on your own.

cereal 1,524 Nearly a Senior Poster Featured Poster

So, have you tried the link formed by get_bloginfo('template_directory') and /banner/728x90.JPG? Do you get relative or absolute path?

cereal 1,524 Nearly a Senior Poster Featured Poster

Without the semicolon otherwise you comment the line and it's not considered: extension=php_printer.dll

After you save the file reload the server and it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to install it from PECL: http://www.php.net/manual/en/printer.installation.php
And it seems to be Windows only.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, just a note, if you use file_get_contents() you don't need fopen/fwrite
This is the page form:

<html>
<head>

    <title>test</title>

</head>

<body>

    <form method="post" action="grab.php">
        <textarea name="files"></textarea><br />
        <input type="submit" name="button" value="save files" />
    </form>

</body>

</html>

And this is grab.php

<?php

if($_SERVER['REQUEST_METHOD'] == 'POST')
{

    function get_link($data)
    {
        preg_match_all('/http(s)?:\/\/(.*)/i', $data, $matches);
        $result = array();
        foreach($matches[0] as $link)
        {
            $result[] = trim(strip_tags($link));
        }
        return $result;
    }

    function head($url,$length)
    {
        $h = array();
        $mimes = array(
            'image/jpeg',
            'image/pjpeg',
            'image/png',
            'image/gif'
        );

        # reference: http://www.php.net/manual/en/function.filesize.php#92462
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_NOBODY, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);

        // not necessary unless the file redirects (like the PHP example we're using here)
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

        $data = curl_exec($ch);
        curl_close($ch);
        if ($data === false)
        {
            return false;
        }

        else
        {
            if (preg_match('/Content-Type: (\d+)/', $data, $matches))
            {
                $h['Content-Type'] = (int)$matches[1];
            }

            if (preg_match('/Content-Length: (\d+)/', $data, $matches))
            {
                $h['Content-Length'] = (int)$matches[1];
            }

            $result[] = !isset($h['Content-Type']) ? false : in_array($h['Content-Type'],$mimes);
            $result[] = (!isset($h['Content-Length']) || ctype_digit($h['Content-Length']) || $h['Content-Length'] < $length) ? true:false;
        }            


        return in_array(true,$result,true);
    }


    function save_files($config)
    {

        $data   = $config['files'];
        $path   = $config['path'];
        $limit  = $config['limit'];
        $length = $config['length'];

        $f = get_link($data);
        $list = array();
        $c = (count($f) < $limit) ? count($f):$limit;

        if(!is_writable($path))
        {
            die('path is not writeable');
        }



        for($i = 0; $i < $c; $i++)
        {
            $file = pathinfo(parse_url($f[$i],PHP_URL_PATH));

            if($file['basename'] == true)
            {

                # check headers
                $h = head($f[$i],$length);
                if($h == true)
                {
                    $remote_data = file_get_contents($f[$i]);

                    # check if file exists and, in case, rename it
                    if(!file_exists($path.$file['basename']))
                    {
                        $name = $file['basename']; …
cereal 1,524 Nearly a Senior Poster Featured Poster