403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.217.143
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/home2/cgny/cron/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/home2/cgny/cron//caltask.php
<?php

declare(strict_types=1);

require __DIR__ . '/db-config.php';

$script = 'caltask';

try {
    $db = cgny_db_connect();

    $db->query(
        "UPDATE ActivityPlanner
         SET numdays = DATEDIFF(dateend, datestart) + 1
         WHERE id > 491635
         AND dateend > '2025-09-01'
         AND numdays = 0
         AND datestart <> dateend"
    );
    $numdaysUpdated = $db->affected_rows;

    $db->query(
        "UPDATE ActivityPlanner
         SET numdaystag = IF(numdays <= 3, 1, 2)
         WHERE dateend > NOW()
         AND numdaystag = 0"
    );
    $numdaystagUpdated = $db->affected_rows;

    $result = $db->query(
        "SELECT id, name, datestart, dateend
         FROM ActivityPlanner
         WHERE (seo_friendly IS NULL OR seo_friendly = '')
         AND id NOT IN (9939, 171250, 174319, 116527)
         AND name <> ''
         ORDER BY id
         LIMIT 50"
    );

    $seoUpdated = 0;
    $checkStmt = $db->prepare('SELECT id FROM ActivityPlanner WHERE seo_friendly = ? LIMIT 1');
    $updateStmt = $db->prepare('UPDATE ActivityPlanner SET seo_friendly = ? WHERE id = ?');

    while ($row = $result->fetch_assoc()) {
        try {
            $moveurl = build_seo_slug($row['name'], $row['datestart'], $row['dateend']);

            $checkStmt->bind_param('s', $moveurl);
            $checkStmt->execute();
            $checkStmt->store_result();

            if ($checkStmt->num_rows > 0) {
                $suffix = date('md-His');
                $moveurl .= '-' . $suffix;
            }
            $checkStmt->free_result();

            $id = (int) $row['id'];
            $updateStmt->bind_param('si', $moveurl, $id);
            $updateStmt->execute();
            if ($updateStmt->affected_rows > 0) {
                $seoUpdated++;
            }
        } catch (Throwable $e) {
            cgny_cron_log($script, 'SEO skip id ' . $row['id'] . ': ' . $e->getMessage());
        }
    }

    $checkStmt->close();
    $updateStmt->close();
    $result->free();

    cgny_cron_log(
        $script,
        sprintf(
            'OK numdays=%d numdaystag=%d seo=%d',
            $numdaysUpdated,
            $numdaystagUpdated,
            $seoUpdated
        )
    );
} catch (Throwable $e) {
    cgny_cron_log($script, 'ERROR ' . $e->getMessage());
    fwrite(STDERR, $e->getMessage() . PHP_EOL);
    exit(1);
}

function build_seo_slug(string $name, string $datestart, string $dateend): string
{
    $seodate = date('Y-m-d', strtotime($datestart)) . '-' . date('Y-m-d', strtotime($dateend));

    $moveurl = preg_replace('/([^[:alnum:][:blank:]]) /', '', $name);
    $moveurl = preg_replace('/[^a-z0-9]+/i', '-', $moveurl);
    $moveurl = str_replace([' ', "'"], '-', $moveurl);

    while ($moveurl !== '' && $moveurl[0] === '-') {
        $moveurl = substr($moveurl, 1);
    }
    while ($moveurl !== '' && $moveurl[0] === '-') {
        $moveurl = substr($moveurl, 1);
    }

    return strtolower(rtrim($moveurl, '-')) . '-' . $seodate;
}

Youez - 2016 - github.com/yon3zu
LinuXploit