예제 #1
0
$code = get_input('code');
// validate input
if (empty($guid)) {
    register_error(elgg_echo('error:missing_data'));
    forward(REFERER);
}
$ia = elgg_get_ignore_access();
$entity = get_entity($guid);
if (empty($entity)) {
    // does the entity exist
    if (!elgg_entity_exists($guid)) {
        register_error(elgg_echo('actionunauthorized'));
        forward(REFERER);
    }
    // validate code
    if (empty($code) || !newsletter_validate_commandline_secret($guid, $code)) {
        register_error(elgg_echo('newsletter:entity:error:code'));
        forward(REFERER);
    }
    // code is valid, so get the entity
    $ia = elgg_set_ignore_access(true);
    $entity = get_entity($guid);
}
// validate entity
if (empty($entity) || !elgg_instanceof($entity, 'object', Newsletter::SUBTYPE)) {
    register_error(elgg_echo('error:missing_data'));
    // restore access
    elgg_set_ignore_access($ia);
    forward(REFERER);
}
// view the newsletter
예제 #2
0
                $value = (int) $value;
                if ($value > 0) {
                    ${$key} = $value;
                }
                break;
            default:
                ${$key} = $value;
                break;
        }
    }
}
if (!empty($secret) && !empty($entity_guid)) {
    ini_set('memory_limit', $memory_limit);
    // start the Elgg engine
    $autoload_root = dirname(dirname(dirname(__DIR__)));
    if (!is_file("{$autoload_root}/vendor/autoload.php")) {
        // installation through composer
        $autoload_root = dirname(dirname(__DIR__));
    }
    require_once "{$autoload_root}/vendor/autoload.php";
    \Elgg\Application::start();
    // vaildate the supplied secret
    if (newsletter_validate_commandline_secret($entity_guid, $secret)) {
        // send the newsletter
        newsletter_process($entity_guid);
    } else {
        exit(elgg_echo('newsletter:cli:error:secret'));
    }
} else {
    exit('Wrong input to run this script, please provide a entity_guid and secret');
}