cereal 1,524 Nearly a Senior Poster Featured Poster

You can use the Open Graph protocol:

For example:

<html prefix="og: http://ogp.me/ns#">
    <head>
        ...
        <meta property="og:title" content="Title of this page" />
        <meta property="od:description" content="Once upon a time..." />
cereal 1,524 Nearly a Senior Poster Featured Poster

Regarding the integers it seems all fine. Are you allowing negative integers?

Because if the integer column in the database is unsigned the negative value will be translated to 0, test:

> create table test(id int unsigned not null);
> insert into test (id) values(-200);
Query OK, 1 row affected, 1 warning (0.11 sec)

> show warnings;
+---------+------+---------------------------------------------+
| Level   | Code | Message                                     |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'id' at row 1 |
+---------+------+---------------------------------------------+

> select * from test;
+----+
| id |
+----+
|  0 |
+----+
1 row in set (0.01 sec)

As you see, in such case you will get a warning, but not an error and from PHP it will seem to work as expected.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you can do it on your own, read this:

It explains all the steps to create your own certificates and CA.

RikTelner commented: Thanks +2
cereal 1,524 Nearly a Senior Poster Featured Poster

I'm sorry, I don't know if there is a tool that can do exactly this, search on Google, maybe you can find something that exports the messages to XML and then from there you can create your CSV files.

An alternative is to check their Data API:

By accessing the feed:

GET https://mail.google.com/mail/feed/atom/

You can get the unread messages in XML format, it looks like this:

<entry>
    <title>Subject of the Email</title>
    <summary>First line of the email message...</summary>
    <link rel="alternate" href="http://mail.google.com/mail?account_id=yourmail@gmail.tld&amp;message_id=random_alnum&amp;view=conv&amp;extsrc=atom" type="text/html" />
    <modified>2014-01-18T13:01:02Z</modified>
    <issued>2014-01-18T13:01:02Z</issued>
    <id>tag:gmail.google.com,2004:random_integer</id>
    <author>
        <name>Sender Name</name>
        <email>email@domain.tld</email>
    </author>
</entry>

From the feed you can get some of the needed information, but you still do not get the full message body, so if you want to extract links from there you need an IMAP or POP access and a parser, as suggested in my previous post.

cereal 1,524 Nearly a Senior Poster Featured Poster

In MySQL you can use a fulltext search. Create an index with skill column:

alter table skills add fulltext skillindx(skill);

then you can use queries like this:

select * from skills where match(skill) against('mysql');

There are some limitations that can be bypassed if you properly configure the database server. The MySQL documentation explains everything:

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Not even because, according to the RFC3696 an email like this one:

test\@mydomain.com@evil.org

is still a valid email address.

Tpojka commented: Helped me with better understanding of mailing services +2
cereal 1,524 Nearly a Senior Poster Featured Poster

@matrixdevuk be careful with this solution, because strstr() will check only for the first occurence of the searched pattern, so if I submit something like this:

mydomain.net@evil.org

it will pass this check.

Docs: http://php.net/strstr

cereal 1,524 Nearly a Senior Poster Featured Poster

If these titles are in database table then you could run an update query to remove them, for example if you have a table like this:

CREATE TABLE `lyrics` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=myisam DEFAULT CHARSET=utf8;

insert into lyrics (title) values('random title - more random title lyrics');
insert into lyrics (title) values('wow random title - another more random title lyrics');
insert into lyrics (title) values('not wow random title - wow wow more random title lyrics ex');

Then the select it would look like this:

> select * from lyrics;
+----+------------------------------------------------------------+
| id | title                                                      |
+----+------------------------------------------------------------+
|  1 | random title - more random title lyrics                    |
|  2 | wow random title - another more random title lyrics        |
|  3 | not wow random title - wow wow more random title lyrics ex |
+----+------------------------------------------------------------+

The update query would consists in a subquery that removes the part of string before the - character and the single word lyrics:

UPDATE lyrics, (SELECT sub.id, trim(sub.newtitle_2) AS newtitle FROM (SELECT id, @newtitle_1:= CASE WHEN title REGEXP 'lyrics' THEN REPLACE(title, 'lyrics', '') END, @position:= INSTR(@newtitle_1, '-'), CASE WHEN @position > 0 THEN SUBSTRING(@newtitle_1, @position+1) END AS newtitle_2 FROM lyrics) AS sub) AS sub2 SET lyrics.title = sub2.newtitle WHERE lyrics.id = sub2.id AND sub2.newtitle IS NOT NULL;

The result of this looks like:

select * from lyrics;
+----+-------------------------------+
| id | title                         |
+----+-------------------------------+
|  1 | more random …
cereal 1,524 Nearly a Senior Poster Featured Poster

I did not tested with Gmail but check the Mailparse library:

cereal 1,524 Nearly a Senior Poster Featured Poster

Not sure if this is related but there are transmission rates, if you send more than 150/200 mails in 15 minutes to the same domain you can get blacklisted.

Each mail provider is different for limits and sensibility.

A part that, if you're sending mails through Gmail SMTP you're limited to 500 mails per day, where: each recipient counts one email and each email can have no more than 100 recipients. So if you send five emails with 100 recipients each, you hit the daily limits.

cereal 1,524 Nearly a Senior Poster Featured Poster

This:

return Redirect::route('worktable1.show', $data);

Will redirect the request to another method. In your routes.php file you should have something similar to this:

Route::get('/page/{guid?}', array(
    'uses' => 'WorktableController@getPage',
    'as' => 'worktable1.show'
));

So, what you should show to us is the method that receives this datum, not the one from which you send it. Also don't change the view, $data in my example is an array to pass the variables to the view, so:

{{ Form::hidden('guid', $guid) }}

If for example you set more than one variable in the method controller:

public function getPage($guid)
{
    $data['guid'] = $guid;
    $data['msg'] = 'hello world';

    return View::make('page.form', $data);
}

Then in the view, you can do this:

{{ $guid }}

{{ $msg }}
cereal 1,524 Nearly a Senior Poster Featured Poster

Have you defined the variable in the method of the controller? For example:

public function getPage($guid)
{
    $data['guid'] = $guid;
    return View::make('page.form', $data);
}
cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, that can happen if there's a glitch in downloading our javascript file. Because once it downloads once, it gets saved locally, if you have a corrupted version of it, nothing will work until you empty your cache. Obviously not a DaniWeb-specific thing. :)

I see a match between these issues and the facebook like button: sometimes it doesn't load and when this happens the navigation dropdown and the watch article button do not work. If I'm not wrong this could explain the failed submits also. I think it could be related to this:

<script type="text/javascript">

// Add a script element as a child of the body
function downloadJSAtOnload() {
    var element = document.createElement("script");
    element.src = "/articles/js_deferred_scripts/group1099512299955946";
    document.body.appendChild(element);
}

// Check for browser support of event handling capability
if (window.addEventListener)
    window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
    window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;    
</script>

May be document.addEventListener("DOMContentLoaded" instead of window.addEventListener("load"?

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe this can be helpful: if I try to refresh the page, after a failed submit, like right now, the browser asks me if I really want to reload the page because it will resubmit the request. In practice I'm accessing the page with a POST request instead of GET.

I loaded Chrome Console and this is the screenshot:

http://imagizer.imageshack.us/v2/1600x1200q90/843/uuug.png

Did this problem just start happening recently or has it existed for many, many months or years?

I noticed this problem just yesterday.

cereal 1,524 Nearly a Senior Poster Featured Poster

After you posted your reply, did you immediately see your message show up? And then you refreshed the page and it was gone?

In my case no, it never appeared and it just happened here with this reply.

cereal 1,524 Nearly a Senior Poster Featured Poster

I had the same issue this morning (more or less when mattyd reported the problem), I was posting my reply in the PHP forum, the page reloaded but my post was not there. At that moment I thought I erroneously reloaded the page. It was a simple message with a code example and maybe a link... dunno how to reply the issue, but in this specific case the thread was marked solved while I was writing... not sure this information can help.

cereal 1,524 Nearly a Senior Poster Featured Poster

It can be done also at query level by using dayofweek(). Differently from PHP the range is 1-7: 1 for sunday, 7 for saturday, for example:

 select * from images where dayofweek(created_at) NOT IN(1,7);

Docs: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_dayofweek

cereal 1,524 Nearly a Senior Poster Featured Poster

Which version of modsecurity module are you using? What I can suggest, for the moment, is to try to reinstall the module by using the newer version.

Also, the modsecurity devs suggests to check if Apache and modsecurity are using the same PCRE library: usually Apache comes with a bundled library, modsecurity instead links to the one used by the operative system. This can lead to unexpected results. To solve it you have to follow these instructions:

In addition, in my previous post I was referring to this error:

ModSecurity: Rule execution error - PCRE limits exceeded (-8): (null). [hostname "<HOSTNAME>"] [uri "/formprocess.php"] [unique_id "UtaWdW1shFcAAE1uMBUAAAAG"]

the PCRE rule in the main config is a general rule that is used by other rule sets. In my box, for example, these rule sets are in:

/usr/share/modsecurity-crs/

And are divided by base, experimental and optional sets. There's also a directory (util) with the regression tests. Now if there are third party rule sets, it may be possible that one of these rules is interfering with the main because is malformed. For this reason I was asking about the rule id and the filename, which is missing from the log. This is strange unless the general log does not return this information, but with the ID you could apply the SecRuleRemoveById directive to stop that particular check.

I don't have other ideas. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, what is missing here is the rule that generates the error, between Rule and execution error there should be the rule id and the filename in which this is saved.

Try to increase to 9 the level of the mod_security debug log, then reload Apache:

SecDebugLog /tmp/modsecurity_debug.log
SecDebugLogLevel 9

And reload the test page. See if you get other useful information. A part this, it can be useful to see the contents of mod_security.conf.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi! If your current errors are the same of the above (Aug 2013) there are also few permissions errors, maybe Apache cannot write/read to those DBM files?

cereal 1,524 Nearly a Senior Poster Featured Poster

cereal I think.

Confirmed.

Come back with your posse and then we'll talk.

lol!

cereal 1,524 Nearly a Senior Poster Featured Poster

True, in this case the documentation is not very clear. But the second argument can be omitted if you pass only the first one:

$row = pg_fetch_array($movie_file_result);

this is possibile because the default value of the third argument is PGSQL_BOTH:

array pg_fetch_array ( resource $result [, int $row [, int $result_type = PGSQL_BOTH ]] )

Which will return an associative and indexed array, in an style similar to this:

array(
    0 => array(
        0 => 'value',
        'title' => 'value',
    ),
    1 => array(
        1 => 'value 2',
        'title' => 'value 2',
    )
);
cereal 1,524 Nearly a Senior Poster Featured Poster

The pg_fetch_array() function takes 3 arguments, not 2, so change it to:

while ($filesrow = pg_fetch_array($movie_file_result, NULL, PGSQL_ASSOC))

Documentation:

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

You can use Gparted to create or resize the partitions, but you have to start linux from a liveCD or an USB so you can change the partition without corrupting the operative system.

For more information check these links:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

Check the documentation:

In particular:

Note: Each of your applications will need its own index.php file which calls the desired application. The index.php file can be named anything you want.

So, in the main index.php file change the application path, i.e. change this:

$application_folder = 'application';

To:

$application_folder = 'application/frontend';

For the admin application create a directory, let's say backend, put a copy of the index.php file there and make it point to the admin app, so:

$application_folder = 'application/admin';

To complete the operation put a copy of the .htaccess file inside the backend directory and change it to use this directory as base of the rewrites:

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

Now, when you want to access the admin panel go to http://localhost/backend/ and everything should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Check also HipHop: https://github.com/facebook/hhvm is used to convert PHP to C++ and speed up the execution of the code.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

from the command line check if the oci8 module is loaded:

php -r 'echo extension_loaded("oci8") ? "true":"false";';

You can also list all the modules loaded by using:

php -m

The PHP version used in command line is known as CLI version and the configuration of this is usually different from the Apache version. They use different php.ini files. So if in the Apache version you see extension=oci8.dll or something similar, copy this to the php.ini of the CLI version and it should work.

Also by using oci_connect() do you get the same error? Ocilogon is an alias of oci_connect and the alias is deprecated since PHP 5.4.0.

More information about the installation process:

cereal 1,524 Nearly a Senior Poster Featured Poster

Yep. You can use 4-28/4 or the equivalent in V7 standard: 4,8,12,16,20,24,28.

cereal 1,524 Nearly a Senior Poster Featured Poster

It means that you have to compare the date string with the one in the filenames and get the most recent. I suppose you cannot consider ctime/mtime/atime, correct? Because if one of the old files is changed it will prompt ahead.

I'm not good with bash scripts but here's an example that seems to work fine:

#!/bin/bash

cd $REP_DATAS/path

current=$(date -u --date='now' '+%F %H:%M')
file_is_old=3
limit=$file_is_old
result=''

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])_([0-9]{4})'
list='*.tar.Z'

for file in $list
    do
        if [[ $file =~ $dateQ ]]
        then

            match=$BASH_REMATCH

            year=${match:0:4}
            month=${match:4:2}
            day=${match:6:2}
            hour=${match:9:2}
            minute=${match:11:2}

            check=$(date -u --date="$year-$month-$day $hour:$minute" '+%F %H:%M')

            diff ()
            {
                printf '%s' $(($(date -u --date="$current" +%s) - $(date -u --date="$check" +%s)))
            }

            fileage=$(($(diff) / 60 / 60 / 24))

            if [ $fileage -le $limit ]
            then
                let limit=fileage
                export result="$file"
            else
                continue
            fi

            if [ $fileage -ge $file_is_old ]
            then
                result="-en \E[47;31m\033[1m Warning: $file is old \033[0m\n"
                tput sgr0
            else
                result=$file
            fi

        fi
    done

echo $result

I'm sure this can be rewritten a lot better, so before using it wait for other suggestions or, better, check the bash documentation.

Reference:

Good luck! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes. 1-31 is the range, you can use * which, in this case, is the same because cron internally sets the first_dom constant to be always 1 and the last_dom constant to be always 31.

So when you write:

*/4

And:

1-31/4

You get the same result. If you want to perform a task every 4 days of the first 20 days of the month you would write:

1-20/4

In the cron source this is done by this loop in the entry.c file:

/* range. set all elements from num1 to num2, stepping
 * by num3.  (the step is a downward-compatible extension
 * proposed conceptually by bob@acornrc, syntactically
 * designed then implmented by paul vixie).
 */
for (i = num1;  i <= num2;  i += num3)
    if (EOF == set_element(bits, low, high, i))
        return EOF;

In PHP it's like writing this:

<?php

define('FIRST_DOM', 1);
define('LAST_DOM', 31);

# 1-31/4
$dom = '1-31';
$step = '4';
$range = array();

switch(true)
{
    case is_null($step) === FALSE && ctype_digit($step):
        $num3 = $step;
        break;
    default:
        $num3 = LAST_DOM - FIRST_DOM + 1;
        break;
}

switch($dom)
{
    case preg_match('/^(\d{1,2}\-\d{1,2})/', $dom, $match) == 1:
        $nums = explode('-', $match[1]);
        $num1 = $nums[0];
        $num2 = $nums[1];
        break;
    case ctype_digit($dom):
        $num1 = $dom;
        $num2 = LAST_DOM;
        break;
    default:
    case '*':
        $num1 = FIRST_DOM;
        $num2 = LAST_DOM;
        break;
}

for($i = $num1;  $i <= $num2;  $i += $num3)
{
    $range[] = $i;
}

echo implode(',', $range);

But you can also use:

# */4
$dom = '*'; …
cereal 1,524 Nearly a Senior Poster Featured Poster

The day of the month (DOM) refers to the 1-31 range, it does not consider when the job was created. There's a comment in cron.c source, extended in the FEATURES file that explains a bit how it works:

the dom/dow situation is odd. '* * 1,15 * Sun' will run on the first and fifteenth AND every Sunday; '* * * * Sun' will run only on Sundays; '* * 1,15 * ' will run *only the 1st and 15th. this is why we keep 'e->dow_star' and 'e->dom_star'. I didn't think up this behaviour; it's how cron has always worked but the documentation hasn't been very clear. I have been told that some AT&T crons do not act this way and do the more reasonable thing, which is (IMHO) to "or" the various field-matches together. In that sense this cron may not be completely similar to some AT&T crons.

DOW stands for Day Of Week, i.e. the last asterisk.

You could also write 1-31/4 to get the same result of the previous suggestions. The comma delimited list is known as V7 standard, from the Unix Programmer's Manual of Bell Labs, page 400:

a list of numbers separated by commas meaning any of the numbers;

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Please give us more information. If you can login through FTP/SSH then you should be able to edit the config file and you can change the value of WP_SITEURL, that should fix the problem:

define( 'WP_SITEURL', 'http://domain.tld/wordpress' );

Reference:

If you cannot access in any way, then you have to contact the hosting company assistance.

cereal 1,524 Nearly a Senior Poster Featured Poster

I do not like how you can see the .htaccess file on the FTP listing.

The .htaccess files are usually available to the clients so they can apply some rules to their websites, as url rewrites, or restricted areas. But if you apply an authentication method for your users, then it's better to apply it in the Directory context.

are you referring to the CONF file in the apache folder here?

In your case probably yes, I'm not used to Windows setups. In Linux environments the Apache configuration files are usually splitted in:

  • few server config files: httpd.conf, apache2.conf and modules files
  • and many virtual host config files, one per each domain

the firsts are general for all the websites, the others are specific to each website. When Apache loads the configuration will merge all these files. The different areas of this flow is identified in the Apache documentation by the context directive:

In fact, if you look at the Apache core documentation, you will see for each directive the context in which this can be applied. Check the previous post link to the Directory directive, for example.

Note: In your screenshot I see:

<Directory />
    # rules
</Directory>

Keep in mind that / stands for the root of the system, in Apache this is called ServerRoot, you should define a DocumentRoot and setup the Directory to point the same path, something like:

<VirtualHost *:80>

    # other rules …
cereal 1,524 Nearly a Senior Poster Featured Poster

Having some issues with securing my home FTP server running FileZilla FTP Server.

Ok, sorry I was confused by the above.

The name of the file must be .htaccess not pass.htaccess. This is a filename which starts by dot. Otherwise it will not be considered by Apache.

Instead of using .htaccess that can be edited by a user accessing through FTP, you can apply these rules in server or virtual host config, in the Directory directive:

<Directory "E:/FTP Data/Optimo Movement">
    AllowOverride All
    AuthType Basic
    AuthName "Restricted Area"
    AuthBasicProvider file
    AuthUserFile "C:/Document and Settings/Patrick/MyDocuments/ftp-pass.txt"
    Require valid-user
</Directory>

The AuthGroupFile is not mandatory, so, if you don't use a file to identify groups, it can be removed.

When you have finished reload Apache and it should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

It should work minimum once evenif the file is two weeks old. The objective is just to display the date of file, if its not new, it will disply in red message as alert that file is very old.

This is very different from what you were asking in your previouses posts.

To get files with a date in the filename change the pattern to match the numbers, something like:

dateQ='([0-9])'

Or:

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])'

An updated version of the script:

#!/bin/bash
cd $REP_DATAS/path

dateQ='20[0-9]{2}(0[1-9]|1[0-2])([0-2][0-9]|3[0-1])'

list='*.tar.Z'

for file in $list
do
    if [[ $file =~ $dateQ ]]
    then
        echo $file
    fi
done

If you still have problems post your updated script and explain exactly your goals.

cereal 1,524 Nearly a Senior Poster Featured Poster

line 6: [: -eq: unary operator expected

The error means $u is missing or is null, so this fails:

if [ ${u} -eq 1 ] ; then

In my example this is defined by:

u=$(date +%u)

So it should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Regarding your first issue, this is probably caused by nl2br, everytime you print the code to the textarea it will translate the new lines to <br />, but it will not remove the new lines. If you remove strip_tags() from the below script, add few lines to the textarea and start to resubmit the form, you will see how the newlines will multiply.

Regarding your second issue, if those are integers then use trim() and intval() so you remove extraspaces and if the submitted datum is not an integer, it will return 0.

Here's an example:

<?php

    $reg_info = 'Hello World';
    $reg_contact_h = 12;
    $reg_contact_m = 17;

    if($_POST)
    {
        print_r($_POST);

        $reg_info = nl2br(strip_tags($_POST['reg_info']), true);
        $reg_contact_h = intval(trim($_POST['rqst_contact_h']));
        $reg_contact_m = intval(trim($_POST['rqst_contact_m']));
    }

?>
<html>
    <head>
        <title>Eban Bury Test Page</title>
    </head>
    <body>
        <form method="post" action="">
            <textarea name="reg_info" cols="45" rows="5" class="roundedfield" id="reg_info"><?php if (!empty($reg_info)) echo htmlspecialchars($reg_info, ENT_NOQUOTES, 'UTF-8'); ?></textarea>

            <label for="rqst_contact_h"></label>
            <input type="text" name="rqst_contact_h" class="roundedfield" id="rqst_contact_h" value="<?php if (!empty($reg_contact_h)) echo $reg_contact_h; ?>" size="20">

            <label for="rqst_contact_m"></label>
            <input type="text" name="rqst_contact_m" class="roundedfield" id="rqst_contact_m" value="<?php if (!empty($reg_contact_m)) echo $reg_contact_m; ?>" size="20">

            <input type="submit" name="submit" value="send" />
        </form>
    </body>
</html>

Hope it helps, bye! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to zip it. By the way for me it works fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can change the approach: with $dateQ you set also the time segment %H%M, not only the day, so if you search for a file of 20140106 you find it only if you match also the hour and the minute segment, i.e.: 1655.

If you cannot avoid the time segment in filenames, then you can change $dateQ to generate only the date segment, so:

dateQ=`date --date='-3 day' +'%Y%m%d'`

instead of:

dateQ=`date --date='-3 day' +'%Y%m%d_%H%M'`

and use it as a regular expression to match the file:

#!/bin/bash
cd $REP_DATAS/path
u=$(date +%u)

if [ ${u} -eq 1 ] ; then
dateQ=`date --date='-3 day' +'%Y%m%d'`
else
dateQ=`date --date='-1 day' +'%Y%m%d'`
fi

list='*.tar.Z'
for file in $list
do
    if [[ $file =~ $dateQ ]]
    then
        zcat $file | tar xvf -
    fi
done

Where list can also be limited to the last 10 modified files, so the script does not have to loop against all files:

list='ls -t *.tar.Z | head -n 10'

You can change it as you prefer.

Note a part: you were using %H%m which will print hourmonth not hourminutes, so use %M to get the minutes.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

the .htaccess file is used for HTTP connections, not for FTP access. The article in LH talks about HTTP Authentication: when you open an URL it appears a prompt that asks for username and password, those specified in .htpasswd. If Apache is properly configured then the HTTP access will be limited to the DocumentRoot of the server, but an FTP user will have complete access unless you don't jail it to a specific path (i.e. directory).

In order to secure your FTP server follow these instructions:

There is an example that explain how to add users to Filezilla Server, those users will be able to access your server. Disable also anonymous access, i.e. remove the anonymous user.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, so the error is file not found or something else? Currently you're not checking if the file is available, try to add a check, and change the extracting command, an example:

file=filename_$dateQ.tar.Z

if [ -f $file] ; then
zcat $file | tar xvf -
else
echo "$file not found"
fi
cereal 1,524 Nearly a Senior Poster Featured Poster

Add $ to "dateQ" otherwise you get filename_dateQ.tar.Z instead of the date & time string:

tar xvf filename_"$dateQ".tar.Z
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you could use an external script and run it daily with cron job to set up a meta key in wp_postmeta, the name can be post_of_the_day, the value a Unix timestamp. An example:

<?php

    # config
    $dbhost = 'localhost';
    $dbname = 'database_name';
    $dbuser = 'database_username';
    $dbpass = 'database_password';

    $pdo = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass);

    $pdo->beginTransaction();

    $stmt = $pdo->prepare("SELECT id FROM wp_posts as p WHERE p.id NOT IN(SELECT post_id FROM wp_postmeta AS pm WHERE p.id = pm.post_id AND pm.meta_key = ?) ORDER BY RAND() LIMIT 1");

    $stmt->execute(array('post_of_the_day'));

    if($stmt->rowCount() > 0)
    {
        $row = $stmt->fetch(PDO::FETCH_ASSOC);

        $stmt2 = $pdo->prepare("INSERT INTO wp_postmeta (post_id, meta_key, meta_value) values(?, ?, UNIX_TIMESTAMP())");

        $stmt2->execute(array($row['id'], 'post_of_the_day'));
    }

    $pdo->commit();

With the above you select a random post between those not used as post of the day. Then change the parameters of $cb_breaking_args to select only one post and order by meta_value:

$cb_breaking_args = array(
    'meta_key' => 'post_of_the_day',
    'post_type' => 'post',
    'numberposts' => '1',
    'category' => $cb_breaking_cat,
    'orderby' => 'meta_value',
    'order' => 'DESC',
    'post_status' => 'publish',
    'suppress_filters' => false
    );

$cb_news_posts = wp_get_recent_posts($cb_breaking_args);

If it works fine you will get the post selected by the external script. Then, the meta key post_of_the_day can be used to create a list of all these posts.

The best would be to use a datetime column for the meta_value, but I'm not sure it is possible to alter or add columns to WordPress and make it work without too many changes in the core code. For this reason I chose a Unix timestamp …

cereal 1,524 Nearly a Senior Poster Featured Poster

Move the form opening and closing tags outside the IF / ELSE statements, currently:

  • when the user is not logged the form is not closed;
  • when the user is logged the opening tag is missing and for this reason is not submitted.

You could also use a completly different form and use method GET: because you're not going to create or update any data, just logging out.

cereal 1,524 Nearly a Senior Poster Featured Poster

To run these kind of events consider to use Gearman, Beanstalkd or other work queues:

It enables you to perform parallel and background tasks in local or remote servers, and does not limit you to PHP, you can use Python or other supported languages. For example: the client in PHP, the worker in C.

The queues can be persistent and in that case will be logged to a database table.

cereal 1,524 Nearly a Senior Poster Featured Poster

Consider also the PDO library, it supports more databases: MySQLi is limited to MySQL and his forks, while PDO can query MySQL, Oracle, SQlite, PostgreSQL, MSSQL and others.

That way you can change database without worrying about rewriting all the code with the specific extensions.

mattyd commented: Thank you. +7
cereal 1,524 Nearly a Senior Poster Featured Poster

Is the dbms_output enabled? If you run show errors do you get any information?

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use preg_match(), an example:

<?php

$string = "Decrypt the following random string: O2tsOGJeLj0saj07ODM1IQ==";

preg_match('/:\s(.*)/', $string, $match);

print_r($match[1]);

The pattern /:\s(.*)/ searches the string after :, but you could also use explode():

$res = explode(':', $string);
echo trim($res[1]);

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

No, the temporary table is visible only by the current connection, if you start a connection from another mysql client (PHPMyAdmin or just a shell) the id will be different. This means that you can have more then one temporary table Basket at the same time:

When using persistent connections, these will be cached and reused if using the same credentials.

cereal 1,524 Nearly a Senior Poster Featured Poster

With mysql_pconnect() you can create temporary tables, these will not be destroyed when the script ends, because the connection will stay open, unless you don't use mysql_close() or you drop the table: