I have a plugins system with update notification. The update notification works, but I made some changes so that the script will execute every hour instead of everytime the page loads. This is handled by the (time() + 3600) being written to a check.cfg file. I wanted to to cut down on the page execution time, especially if the user has quite a few plugins installed. Along with this change, I wanted to write the results to the database for each plugin. However, it doesn't get written to the database, and I believe it has something to do with when the check.cfg file is called and/or updated. Below is the code. Any help is greatly appreciated.
if(!file_exists(PM_CONTENT_DIR . 'check.cfg')) {
touch(PM_CONTENT_DIR . 'check.cfg');
}
$checkFile = file_get_contents( PM_CONTENT_DIR . 'check.cfg', true);
if((int)$checkFile > time()) {
/* Do not update */;
} else {
$pUpgrade = explode("\n", @file_get_contents( "http://git.plugins.projectpress.org/" . $plugin_info['Plugin Slug'] . ".git/raw/master/" . $plugin_info['Plugin Slug'] . ".txt" ) );
if($sql1->num_rows == 0 && $plugin['Plugin Slug'] != $r1['plugin_slug'] && $plugin_info['Version'] < $pUpgrade[1]) {
$sql2 = pmdb::connect()->insert( DB . 'plugin_updates',
array(pmdb::connect()->escape($pUpgrade[0]),
pmdb::connect()->escape($pUpgrade[1]),
pmdb::connect()->escape($plugin),
),
'plugin_slug,
version,
update_url'
);
} else {
$sql3 = pmdb::connect()->update( DB . 'plugin_updates', array( 'version' => $pUpgrade[1]), array( 'plugin_slug', $pUpgrade[0] ) );
}
$fp = fopen(PM_CONTENT_DIR . 'check.cfg', 'w+');
fwrite($fp, time() + get_pm_option('plugin_update_time'));
fclose($fp);
}