예제 #1
0
파일: queue.php 프로젝트: bignunxd/otog
function error($code)
{
    global $message, $text, $score, $timeused;
    echo $code . '\\n';
    $text = 'err';
    $message = $code . '<br>เกรดเดอร์จะหยุดทำงาน และสามารถ start grader ด้วยตัวเองได้แล้ว';
    $score = 0;
    $timeused = 0;
    degrade();
    write();
    shell_exec('sh /home/otog/otog/judge/run.sh');
    die;
}
예제 #2
0
 public function updateTerm($termId, $taxonomy, $args = [])
 {
     if (!$this->taxonomyExists($taxonomy)) {
         return new EtherError('Invalid taxonomy');
     }
     $termId = (int) $termId;
     $term = $this->getTerm($termId, $taxonomy);
     if (!$term) {
         return new EtherError('Invalid Term');
     }
     $term = degrade($term);
     $args = array_merge($term, $args);
     $defaults = ['description' => '', 'parent' => null, 'slug' => ''];
     $args = array_merge($defaults, $args);
     $name = e($args['name']);
     $description = e($args['description']);
     $args['name'] = $name;
     $args['description'] = $description;
     if ('' == trim($name)) {
         return new EtherError('Term name is required');
     }
     if (0 == $args['parent']) {
         $args['parent'] = null;
     }
     if (null != $args['parent'] && !$this->termExists((int) $args['parent'], $taxonomy)) {
         return new EtherError('Term parent not exists');
     }
     if ($args['parent'] == $term['term_id']) {
         return new EtherError('Term parent cannot be the same term');
     }
     if (!empty(trim($args['slug']))) {
         if ($args['slug'] == $term['slug']) {
             unset($args['slug']);
         } else {
             $args['slug'] = $this->termRepository->sluggableTerm($args['slug'], $taxonomy);
         }
     } else {
         unset($args['slug']);
     }
     if (isset($args['id'])) {
         unset($args['id']);
     }
     if (isset($args['term_id'])) {
         unset($args['term_id']);
     }
     $termUpdated = $this->termTaxonomyRepository->updateTermTaxonomy($args, $term['id']);
     if ($termUpdated) {
         Cache::tags(['taxonomies'])->flush();
         return $termUpdated;
     }
     return false;
 }
예제 #3
0
 public function delete($metaType, $objectId, $metaKey, $metaValue = '', $deleteAll = false)
 {
     if (!$metaType || !$metaKey || !is_numeric($objectId) && !$deleteAll) {
         return false;
     }
     $objectId = abs((int) $objectId);
     if (!$objectId && !$deleteAll) {
         return false;
     }
     if (!($repositoryClassInstance = $this->metaRepoExists($metaType))) {
         return false;
     }
     $column = sanitizeKey($metaType . '_id');
     $metaKey = e($metaKey);
     $metaValue = se($metaValue);
     $check = Plugin::apply_filters("delete_{$metaType}_metadata", null, $objectId, $metaKey, $metaValue, $deleteAll);
     if (null !== $check) {
         return (bool) $check;
     }
     $_metaValue = $metaValue;
     $metaValue = jsonizeMaybe($metaValue);
     $findQueryClauses = ['meta_key' => $metaKey];
     if (!$deleteAll) {
         $findQueryClauses[$column] = $objectId;
     }
     if ('' !== $metaValue && null !== $metaValue && false !== $metaValue) {
         $findQueryClauses['meta_value'] = $metaValue;
     }
     $metaIds = degrade($this->{$repositoryClassInstance}->findWhere($findQueryClauses, ['id']));
     if (!count($metaIds)) {
         return false;
     }
     if ($deleteAll) {
         $objectIds = degrade(array_pluck($this->{$repositoryClassInstance}->findWhere(['meta_key' => $metaKey], [$column]), $column));
     }
     Plugin::do_action("delete_{$metaType}_meta", $metaIds, $objectId, $metaKey, $_metaValue);
     $delete = $this->{$repositoryClassInstance}->delete($metaIds);
     if (!$delete) {
         return false;
     }
     if ($deleteAll) {
         foreach ($objectIds as $oId) {
             Cache::tags(["{$metaType}_meta"])->forget($oId);
         }
     } else {
         Cache::tags(["{$metaType}_meta"])->forget($objectId);
     }
     Plugin::do_action("deleted_{$metaType}_meta", $metaIds, $objectId, $metaKey, $_metaValue);
     return true;
 }