Ejemplo n.º 1
0
 public static function enviar()
 {
     global $request;
     $request = R::findAll('request', ' ORDER BY name ');
     $user = R::findAll('user');
     $lista = [];
     $subject = "Lista del super";
     $file = fopen('vistas/email/email.ejs', 'r');
     $content = fread($file, filesize('vistas/email/email.ejs'));
     $message = __($content)->template(array('lista' => $request));
     $header = "From:lista@carrito.esy.es\r\n";
     $header .= "MIME-Version: 1.0\r\n";
     $header .= "Content-type: text/html\r\n";
     foreach ($user as $key => $value) {
         if (isset($value->email) && $value->email != "" && $value->rol == 1) {
             $lista[] = $value->email;
             $to = $value->email;
             $retval = mail($to, $subject, $message, $header);
             if ($retval == true) {
                 echo json_encode($lista);
             } else {
                 echo "Message could not be sent...";
             }
         }
     }
 }
Ejemplo n.º 2
0
 protected function unit($arguments)
 {
     $request = trim($arguments[0]);
     $request = rtrim($request, '!@#$%^&*()_-+={}[]:;\'"\\|<>,./?');
     foreach ($this->lastRequest as $id => $timeToClear) {
         if (time() - $timeToClear >= self::CLEAR_TIME) {
             unset($this->lastRequest[$id]);
         }
     }
     parent::RedBeanConnect(self::DB_NAME);
     if (preg_match('/^[\\x{30A0}-\\x{30FF}\\x{31F0}-\\x{31FF}]+$/iu', $request)) {
         $units = R::findAll(self::TB_NAME, '`orginal` like ?', ["%{$request}%"]);
     } else {
         $units = R::findAll(self::TB_NAME, '`name` like ?', [$request]);
     }
     if ($units) {
         $linkHolder = [];
         foreach ($units as $unit) {
             if (!$unit->linkgc || isset($linkHolder[$unit->linkgc]) || isset($this->lastRequest[$unit->id])) {
                 continue;
             }
             $linkHolder[$unit->linkgc] = $unit->orginal;
             $this->lastRequest[$unit->id] = time();
             $text = IRCHelper::colorText('Romanji', IRCHelper::COLOR_ORANGE) . ': ' . $unit->orginal;
             $text .= ' ' . IRCHelper::colorText('Link', IRCHelper::COLOR_ORANGE) . ': ' . $unit->linkgc;
             $this->reply($text);
         }
     } else {
         $this->reply('Not found ' . $request);
     }
     R::close();
 }
Ejemplo n.º 3
0
 function view($args)
 {
     $id = array_shift($args);
     $permission = R::load('permission', $id);
     if (!is_numeric($id) && !$permission->getID()) {
         $this->redirect(PACKAGE_URL);
     }
     $allgroups = R::findAll('group');
     foreach ($allgroups as $key => $group) {
         foreach ($permission->sharedGroup as $group_c) {
             if ($group->id == $group_c->id) {
                 $allgroups[$key]->checked = true;
             }
         }
     }
     //		echo $permission->name;exit;
     $view = new G2_TwigView('pages/view');
     $view->permission = $permission;
     $view->allGroups = $allgroups;
     $form = new G2_FormMagic($view->get_render());
     if ($form->is_posted()) {
         $groups = R::loadAll('group', array_keys($form->data()['groups']));
         $permission->sharedGroup = $groups;
         R::store($permission);
         Admin_Alert::add_message("\"{$permission->name}\" permission was updated");
         $this->redirect(PACKAGE_URL);
     }
     echo $form->parse();
 }
Ejemplo n.º 4
0
function recupWines()
{
    // Récupération sous forme d'un tableau de tous les vins dans la DB au moyen de l'ORM RedBean
    $tabWines = R::findAll('wine');
    // On retourne le tableau "tabWines"
    return $tabWines;
}
Ejemplo n.º 5
0
 function nav_save()
 {
     G2_User::init();
     if (G()->logged_in() && !empty($_POST)) {
         if (!empty($_POST['items']) && !empty($_POST['identity'])) {
             // Delete all current navigation details
             $navitems = R::findAll('navitem', 'identity=:id', ['id' => $_POST['identity']]);
             R::trashAll($navitems);
             foreach ($_POST['items'] as $new_item) {
                 $nav = R::dispense('navitem');
                 $nav->identity = $_POST['identity'];
                 $nav->label = $new_item['label'];
                 $nav->href = !$new_item['href'] ? null : $new_item['href'];
                 $nav->order = $new_item['order'];
                 //@todo parent node support
                 R::store($nav);
             }
             echo json_encode(['success' => true, 'message' => 'Content Saved Successfully']);
         } else {
             echo json_encode(['success' => false, 'message' => 'Data sent not correct']);
         }
     } else {
         echo json_encode(['success' => false, 'message' => 'Not Logged in']);
     }
     die;
 }
Ejemplo n.º 6
0
 public function process(array $documents, &$context)
 {
     $franchiseIds = [];
     $franchiseIds[] = self::mediaToKey($context->media);
     foreach ($context->relationData as $relation) {
         if ($relation['media'] != $context->media->media) {
             continue;
         }
         if ($relation['type'] == MediaRelation::Character) {
             continue;
         }
         if (BanHelper::isFranchiseCouplingBanned($relation['media'], $relation['mal_id'], $context->media->media, $context->media->mal_id)) {
             continue;
         }
         $franchiseIds[] = self::mediaToKey($relation);
     }
     foreach (R::findAll('media', 'media||mal_id IN (' . R::genSlots($franchiseIds) . ')', $franchiseIds) as $relatedMedia) {
         $franchiseIds[] = $relatedMedia->franchise;
     }
     $franchiseId = reset($franchiseIds);
     $media =& $context->media;
     $media->franchise = $franchiseId;
     R::store($media);
     $query = 'UPDATE media SET franchise = ? WHERE franchise IN (' . R::genSlots($franchiseIds) . ')';
     R::exec($query, array_merge([$franchiseId], $franchiseIds));
 }
 public function getAllSubscriptions($start)
 {
     $users = R::findAll('subscriptions', ' ORDER BY created DESC LIMIT :start, :limit ', array(':start' => $start, ':limit' => LIMIT));
     if (isset($users)) {
         return $users;
     }
     return false;
 }
Ejemplo n.º 8
0
 public function getAll($isBean = false)
 {
     if ($isBean) {
         return R::findAll('guest', 'ORDER BY modify_date DESC');
     } else {
         return R::getAll('SELECT * FROM guest ORDER BY modify_date DESC');
     }
 }
Ejemplo n.º 9
0
 public function getUsernames()
 {
     $users = R::findAll('user');
     $usernames = array();
     foreach ($users as $user) {
         array_push($usernames, $user->username);
     }
     return json_encode($usernames);
 }
 public function getApplications($start)
 {
     if (isset($this->_job_id)) {
         $apps = R::findAll('applications', " job_id=:job_id ORDER BY created DESC LIMIT :start, :limit ", array(':job_id' => $this->_job_id, ':start' => $start, ':limit' => LIMIT));
     } else {
         $apps = R::findAll('applications', " ORDER BY created DESC LIMIT :start, :limit ", array(':start' => $start, ':limit' => LIMIT));
     }
     return $apps;
 }
Ejemplo n.º 11
0
function showLinks()
{
    $base_url = BASE_URL;
    $pages = R::findAll('pages');
    echo "<a href=\"{$base_url}\">Home</a> ";
    foreach ($pages as $page) {
        echo "<a href=\"/{$page['url']}\">{$page['name']}</a> ";
    }
}
Ejemplo n.º 12
0
 function index()
 {
     //Get all Submission Types
     $view = new G2_TwigView('pages/index');
     // Mail Lists
     $lists = R::findAll(Package_Mail::MAIL_LIST);
     $view->set('maillist', $lists);
     $view->render();
 }
Ejemplo n.º 13
0
 public function Get()
 {
     $users = R::findAll('user');
     $newUsers = array();
     foreach ($users as $user) {
         $newUsers[] = array("id" => $user->id, "name" => $user->name, "surname" => $user->surname, "email" => $user->email, "isAdmin" => $user->isAdmin === '1' ? true : false, "isTeacher" => $user->isTeacher, "group" => $user->group);
     }
     return $newUsers;
 }
Ejemplo n.º 14
0
 public function sendMessage()
 {
     echo "Sending a message to all registered devices \r\n";
     $devices = R::findAll('device');
     foreach ($devices as $device) {
         echo "Sending message " . $this->msg . " to device " . $device->token . "\r\n";
         Notification::sendPush($device->token, $this->msg, ["msg" => "Broadcast testing message"], 0);
     }
 }
Ejemplo n.º 15
0
function getUsuarios()
{
    $app = \Slim\Slim::getInstance();
    // query database for all articles
    $usuarios = R::findAll('usuarios', 'ORDER BY user_name');
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($usuarios));
}
Ejemplo n.º 16
0
 /**
  * Handle publication recent results operations /
  *
  * @param object    $context    The context object for the site
  *
  * @return string    A template name
  */
 public function handle($context)
 {
     $pagesize = 5;
     $amount = R::count('publication');
     $page = $context->getpar('page', 1);
     # Find all publications and paginate them.
     $pubs = R::findAll('publication', 'ORDER BY Id desc limit ?,?', [($page - 1) * $pagesize, $pagesize]);
     # Get the URL for the paginator.
     $url = $context->action() . '?';
     # Delegate the publishement bean to the results handler.
     return (new Results($pubs, $url, $pagesize, $amount, $page))->handle($context);
 }
Ejemplo n.º 17
0
 public function __construct($id, $page_id = false)
 {
     //Load items belonging to this $id and page is set;
     $identity = md5($id);
     $this->title = $id;
     $this->id = $identity;
     $navs = R::findAll('navitem', 'identity = :identity ORDER by `order` ASC', ['identity' => $identity]);
     if (empty($navs)) {
         $navs = [$this->loadNav($identity, 'Home', '')];
     }
     $this->nav_items = $navs;
 }
Ejemplo n.º 18
0
function testbook()
{
    global $app;
    try {
        $book = R::findAll('book');
        // 				var_dump($book);
        echo json_encode(R::exportAll($book));
    } catch (Exception $e) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $e->getMessage());
    }
}
Ejemplo n.º 19
0
 public function Get()
 {
     if (isset($_GET["id"])) {
         $books = array(R::load('book', $_GET["id"]));
     } else {
         $books = R::findAll('book');
     }
     $newBooks = array();
     foreach ($books as $book) {
         $newBooks[] = array("id" => $book->id, "name" => $book->name, "file" => $book->file, "author" => $book->author, "year" => $book->year, "production" => $book->production, "keywords" => $book->keywords, "type" => $book->type);
     }
     return $newBooks;
 }
Ejemplo n.º 20
0
function getSegmentosByPage($pagenumber)
{
    $app = \Slim\Slim::getInstance();
    // query database for all segmentos
    $segmentos = R::findAll('segmento', 'ORDER BY nombre LIMIT ?,8', array($pagenumber * 8 - 8));
    // send response header for JSON content type
    $app->response()->header('Content-Type: text/html; charset=utf-8');
    $app->response()->header('Content-Type', 'application/json');
    foreach ($segmentos as $segmento) {
        $segmento->clientes = $segmento->clientes;
    }
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($segmentos));
}
Ejemplo n.º 21
0
 function index($f3)
 {
     $tools = \R::find('tools');
     $D = \R::findAll('toolgroups', 'ORDER BY sort_priority DESC, displayname ASC');
     foreach ($D as $key => $element) {
         $D[$key]->with("ORDER BY displayname ASC")->ownTools;
     }
     $f3->set('toolgroups', \R::exportAll($D));
     $trainings = \R::find('trainings');
     $f3->set('trainings', $trainings ? reset($trainings)->build_lookup($trainings) : false);
     $users = \R::find('users', 'active=1 ORDER BY usergroup ASC, displayname ASC');
     $f3->set('usergroups', $users ? reset($users)->group($users) : $users);
     show_page($f3, 'trainings.index', true);
 }
Ejemplo n.º 22
0
 public static function getCoolUsers($goal)
 {
     $query = 'SELECT id FROM user WHERE cool = 1 ORDER BY RANDOM() LIMIT ?';
     $userIds = array_map(function ($x) {
         return intval($x['id']);
     }, R::getAll($query, [$goal]));
     if (empty($userIds)) {
         return [];
     }
     $query = 'id IN (' . R::genSlots($userIds) . ')';
     $result = R::findAll('user', $query, $userIds);
     return array_map(function ($x) {
         return $x->box();
     }, $result);
 }
Ejemplo n.º 23
0
 /**
  * get all
  *
  * @param bool $isBean
  * @param null|int $limit
  *
  * @return array
  */
 public function getAll($isBean = false, $limit = null)
 {
     if (null !== $limit && is_int($limit)) {
         $limitSql = ' LIMIT ' . (int) $limit . ' ';
     } else {
         $limitSql = '';
     }
     $orderSql = ' ORDER BY id ASC ';
     if ($isBean !== false) {
         $return = R::findAll('xss', $orderSql . $limitSql);
     } else {
         $return = R::getAll('SELECT * FROM xss ' . $orderSql . $limitSql);
     }
     return $return;
 }
Ejemplo n.º 24
0
 function get_posts($post_type, $id = false)
 {
     $posts = R::findAll('post', 'post_type = :post ORDER BY id DESC ', ['post' => $post_type]);
     $posts_populated = [];
     foreach ($posts as $post) {
         $fields = $post->ownPostdata;
         $object = R::dispense('postobject');
         foreach ($fields as $fielddata) {
             $object->{$fielddata->postmeta->fieldname} = $fielddata->value;
         }
         $object->id = $post->id;
         $posts_populated[] = $object;
     }
     return $posts_populated;
 }
Ejemplo n.º 25
0
 function edit_form($f3)
 {
     // Get Toolgroup Options
     $D = \R::findAll('toolgroups', 'ORDER BY sort_priority DESC, displayname ASC');
     $f3->set('toolgroups', \R::exportAll($D));
     // Get Training Levels
     $f3->set('training_levels', $f3->exists('data.training_levels') ? json_decode($f3->get('data.training_levels')) : $f3->get('TRAINING_LEVELS'));
     // Get Location Options
     $D = \R::findAll('locations', 'ORDER BY displayname ASC');
     $f3->set('locations', \R::exportAll($D));
     foreach ($f3->get('locations') as $i => $location) {
         $f3->set('locations.' . $i . '.active', isset($this->D->sharedLocationsList[$locations['id']]));
     }
     parent::edit_form($f3);
 }
Ejemplo n.º 26
0
 static function subscriptionUser($id)
 {
     if (empty($_SESSION['user'])) {
         header("Location: ?ctrl=wisdom&action=GetWisdomById&id=" . $id);
     }
     $requirement = R::findAll('requirements', "WHERE requirements.information_id = ?", [$id]);
     if (empty($requirement)) {
         $information = R::load('information', $id);
         $information->sharedUser[] = $_SESSION['user'];
         R::store($information);
         header("Location:?ctrl=cabinet&action=GetUserInformation&id=" . $id);
     } else {
         header("Location:?ctrl=wisdom&action=GetWisdomById&id=" . $id);
     }
     die;
 }
Ejemplo n.º 27
0
 public static function getLatestBlocks($limit)
 {
     $findAll = R::findAll('blocks', 'order by id desc limit ?', [$limit]);
     $i = 0;
     foreach ($findAll as $findOne) {
         $return[$i]['block'] = $findOne->height;
         $return[$i]['hash'] = $findOne->hash;
         $return[$i]['time'] = strtotime($findOne->time);
         $return[$i]['mint'] = $findOne->mint;
         $return[$i]['flags'] = $findOne->flags;
         $return[$i]['value'] = $findOne->totalvalue;
         $return[$i]['transactioncount'] = $findOne->transactioncount;
         $return[$i]['tx'] = $findOne->tx;
         $i++;
     }
     return $return;
 }
Ejemplo n.º 28
-1
function getEnviosByPage($pagenumber)
{
    //$app->get('/envios/page/:pagenumber', function ($pagenumber) use ($app) {
    $app = \Slim\Slim::getInstance();
    // query database for all contactos
    $envios = R::findAll('envios', 'ORDER BY id LIMIT ?,8', array($pagenumber * 8 - 8));
    // send response header for JSON content type
    $app->response()->header('Content-Type: text/html; charset=utf-8');
    $app->response()->header('Content-Type', 'application/json');
    //die(print_r($envios[0]->ubicaciones));
    foreach ($envios as $envio) {
        $envio->clientes = $envio->clientes;
        $envio->segmento = $envio->segmento;
        $envio->subsegmento = $envio->subsegmento;
        $envio->contactos = $envio->contactos;
        $envio->ubicaciones_origen = R::findOne('ubicaciones', 'id=?', array($envio->ubicaciones_origen_id));
        $envio->ubicaciones_destino = R::findOne('ubicaciones', 'id=?', array($envio->ubicaciones_destino_id));
        $envio->vehiculos = $envio->vehiculos;
        $envio->choferes = $envio->choferes;
        $envio->statuses = $envio->statuses;
    }
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($envios));
    //});
}
Ejemplo n.º 29
-1
 static function execute($number = 5)
 {
     if (!is_numeric($number)) {
         throw new Exception('Number must be numeric');
     }
     $callables = R::findAll('queueitem', 'status = "open" ORDER BY id DESC LIMIT ' . $number);
     $c = 0;
     foreach (array_values($callables) as $index => $calleble) {
         $c++;
         if ($calleble->done) {
             $c--;
             continue;
         }
         if ($c >= $number) {
             break;
         }
         $serializer = new Serializer();
         $closure = $serializer->unserialize($calleble->callser);
         ////			$calleble->status = 'busy';
         //			R::store($calleble);
         $closure();
         $calleble->status = 'done';
         $calleble->done = true;
         $calleble->doneat = time();
         R::store($calleble);
     }
     return;
 }
 public function countJobs($terms)
 {
     $terms = splitTerms($terms);
     $terms = implode('|', $terms);
     $jobs = R::findAll('jobs', " status=1 AND (title REGEXP :title OR description REGEXP :description OR perks REGEXP :perks OR how_to_apply REGEXP :how_to_apply OR company_name REGEXP :company_name)", array(':title' => $terms, ':description' => $terms, ':perks' => $terms, ':how_to_apply' => $terms, ':company_name' => $terms));
     return count($jobs);
 }