The feed deleted for 2 weeks does not work in the cpanel, this error message:
/home/elittagh/public_html/cron/cron.php: line 1: ?php: No such file
or directory
/home/elittagh/public_html/cron/cron.php: line 2: syntax error near
unexpected token `'OSSN_ALLOW_SYSTEM_START','
/home/elittagh/public_html/cron/cron.php: line 2:
`define('OSSN_ALLOW_SYSTEM_START', TRUE);'
cron.php:
<?php
define('OSSN_ALLOW_SYSTEM_START', true);
require_once ('system/start.php');
function delete_2weeks_posts() {
$wall = new OssnWall;
$listUser = $wall->GetPosts(array(
'type' => 'user',
'page_limit' => false,
'wheres' => array(
"(FROM_UNIXTIME(o.time_created) <= DATE_SUB(NOW(), INTERVAL 2 WEEK))"
)
));
if ($listUser) {
foreach ($listUser as $post) {
$post->deleteObject($post->guid);
ossn_trigger_callback('post', 'delete', $post->guid);
}
}
}
delete_2weeks_posts();
Date end.
There are many posts, not just one.
Okay, so there's only 1 Posting which is older than 14 days and only this one would be deleted if you would add the delete code at the bottom.
You may experiment with changing '2 WEEK' to '10 DAY', '5 DAY', '1 DAY' or whatever you like
and you'll see: the smaller the number of days, the more records you'll get.
So the code is working as expected, and I don't see what your problem is?
php /home/elittagh/public_html/cron/posts.php
POSTINGS <pre>1</pre>
Fine, so let's revert the code back to the orginal condition to find only older records.
Remove the three double slashes like
<?php
define('OSSN_ALLOW_SYSTEM_START', true);
require_once ('/home/elittagh/public_html/system/start.php');
$wall = new OssnWall;
$listUser = $wall->GetPosts(array(
'type' => 'user',
'page_limit' => false,
'wheres' => array(
"(FROM_UNIXTIME(o.time_created) <= DATE_SUB(NOW(), INTERVAL 2 WEEK))"
)
));
echo "POSTINGS " . ossn_dump(count($listUser));
and execute the command again.
How many postings do get this time?
$ php /home/elittagh/public_html/cron/posts.php
ALL POSTINGS <pre>31</pre>
You can simply change that last line to
echo "ALL POSTINGS " . ossn_dump(count($listUser));
to see the total number of postings
Okay, so it's basically working.
The interesting part is: how many OssnWall Objects?
I see only two:
[0] => OssnWall Object
and
[1] => OssnWall Object
and both are fairly new
Lots of text, can't be uploaded here.
$ php /home/elittagh/public_html/cron/posts.php
POSTINGS <pre>Array
(
[0] => OssnWall Object
(
[data] => stdClass Object
(
)
[guid] => 1239
[time_created] => 1631263197
[owner_guid] => 3
[description] => {"post":"Hivatalban,adatfelvételkor....\r\n-Vezetékneve?\r\n-Kábel!\r\n-Nem úgy!Hogy hívják?\r\n-Jaa..."}
[title] =>
[type] => user
[subtype] => wall
[item_type] =>
[item_guid] =>
[poster_guid] => 3
[access] => 2
[time_updated] => 0
[linkPreview] =>
)
[1] => OssnWall Object
(
[data] => stdClass Object
(
)
[guid] => 1238
[time_created] => 1631210960
[owner_guid] => 2
[description] => {"post":"Hamarosan indul a nyereményjáték, aki a legtöbb igazolt személyt tudja meghívni az Elittagságba, azt jelentős nyeremény várja majd!"}
[title] =>
[type] => user
[subtype] => wall
[item_type] =>
[item_guid] =>
[poster_guid] => 2
[access] => 2
[time_updated] => 0
[postbackground_type] => pbg3
[linkPreview] =>
)
Yup, so let's debug:
Put this code in another file named posts.php in the same directory
<?php
define('OSSN_ALLOW_SYSTEM_START', true);
require_once ('/home/elittagh/public_html/system/start.php');
$wall = new OssnWall;
$listUser = $wall->GetPosts(array(
'type' => 'user',
'page_limit' => false,
// 'wheres' => array(
// "(FROM_UNIXTIME(o.time_created) <= DATE_SUB(NOW(), INTERVAL 2 WEEK))"
// )
));
echo "POSTINGS " . ossn_dump($listUser);
then execute it like
php /home/elittagh/public_html/cron/posts.php
and tell what the output looks like
It only deletes it if I put the code in index.php.
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)