<?php require_once __DIR__.'/../includes/functions.php'; mj_ensure_listing_module_schema(true); $rows=all_rows("SELECT * FROM mj_listings WHERE (is_sponsored=1 OR is_featured=1) LIMIT 1000"); $n=0; foreach($rows as $r){ $id=(int)$r['id']; if(!empty($r['sponsored_until']) && strtotime($r['sponsored_until'])<time() && (int)($r['is_sponsored']??0)===1){ q('UPDATE mj_listings SET is_sponsored=0,sponsored_priority=0 WHERE id=?',[$id]); mj_listing_log($id,'cron_sponsor_expired',$r,[]); mj_create_admin_alert(['alert_key'=>'sponsor_expired_listing_'.$id.'_'.date('Ymd'),'alert_type'=>'sponsor_expired','module_name'=>'listings','priority'=>'urgent','title'=>'Sponsored listing expired','message'=>'Sponsored listing expired: '.($r['title']??''),'action_url'=>'listing-edit.php?id='.$id,'action_label'=>'Renew','related_type'=>'listing','related_id'=>$id]); $n++; } if(!empty($r['featured_until']) && strtotime($r['featured_until'])<time() && (int)($r['is_featured']??0)===1){ q('UPDATE mj_listings SET is_featured=0,featured_priority=0 WHERE id=?',[$id]); mj_listing_log($id,'cron_featured_expired',$r,[]); mj_create_admin_alert(['alert_key'=>'featured_expired_listing_'.$id.'_'.date('Ymd'),'alert_type'=>'featured_expired','module_name'=>'listings','priority'=>'high','title'=>'Featured listing expired','message'=>'Featured listing expired: '.($r['title']??''),'action_url'=>'listing-edit.php?id='.$id,'action_label'=>'Renew','related_type'=>'listing','related_id'=>$id]); $n++; } } echo "Sponsor/featured expiry processed: $n"; ?>
