예제 #1
0
 public function commit()
 {
     $hash = rand_url_id(12);
     XDB::execute('INSERT INTO  register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
                        VALUES  ({?}, {?}, {?}, NOW(), {?}, {?}, {?})', $this->uid, $this->hruid, $this->email, $hash, $this->user->fullName(), $this->group);
     return true;
 }
예제 #2
0
 public function commit()
 {
     $sql = 'INSERT INTO  surveys
                     SET  questions = {?}, title = {?}, description = {?},
                          uid = {?}, end = {?},mode = {?}, promos = {?}';
     return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->user->id(), $this->end, $this->mode, $this->promos);
 }
예제 #3
0
파일: clean.php 프로젝트: Ekleog/platal
function query($sql)
{
    XDB::execute($sql);
    if (XDB::errno() != 0) {
        echo "error in \"{$sql}\":\n", XDB::error(), "\n";
    }
}
예제 #4
0
 public function commit()
 {
     if ($this->user->hasProfile()) {
         XDB::execute('UPDATE  profiles
                          SET  alias_pub = {?}
                        WHERE  pid = {?}', $this->public, $this->user->profile()->id());
     }
     if ($this->old) {
         $success = XDB::execute('UPDATE  email_source_account
                                     SET  email = {?}
                                   WHERE  uid = {?} AND type = \'alias_aux\'', $this->alias, $this->user->id());
     } else {
         $success = XDB::execute('INSERT INTO  email_source_account (email, uid, domain, type, flags)
                                       SELECT  {?}, {?}, id, \'alias_aux\', \'\'
                                         FROM  email_virtual_domains
                                        WHERE  name = {?}', $this->alias, $this->user->id(), Platal::globals()->mail->alias_dom);
     }
     if ($success) {
         // Update the local User object, to pick up the new bestalias.
         require_once 'emails.inc.php';
         fix_bestalias($this->user);
         $this->user = User::getSilentWithUID($this->user->id());
     }
     return $success;
 }
예제 #5
0
function do_update_by_block($values)
{
    // Update display_tel by block
    // Because there is no mysql update syntax for multiple updates in one query
    // we use a multiple insert syntax which will fail because the key already exist
    // and then update the display_tel
    XDB::execute("INSERT INTO  profile_phones (pid, link_type, link_id, tel_id ,tel_type,\n                                          search_tel, display_tel, pub, comment)\n                       VALUES  " . $values . "\n      ON DUPLICATE KEY UPDATE  display_tel = VALUES(display_tel)");
}
예제 #6
0
/**
 * Purges session events without a valid session.
 */
function purgeOrphanedEvents()
{
    $begin = time();
    XDB::execute("DELETE  e\n           FROM  log_events AS e\n      LEFT JOIN  log_sessions AS s ON (s.id = e.session)\n          WHERE  s.id IS NULL");
    $affectedRows = XDB::affectedRows();
    $duration = time() - $begin;
    echo "Orphaned events: removed {$affectedRows} events in {$duration} seconds.\n";
}
예제 #7
0
파일: todo.php 프로젝트: netixx/frankiz
 function handler_ajax_todo_clear($page)
 {
     S::assert_xsrf_token();
     XDB::execute('DELETE FROM  todo
                         WHERE  uid = {?} AND checked = 1', S::user()->id());
     if (XDB::affectedRows() != 1) {
         $page->jsonAssign('error', "Impossible de nettoyer la liste des tâches");
     }
     return PL_JSON;
 }
예제 #8
0
 public function save(ProfilePage $page, $field, $value)
 {
     XDB::execute("DELETE FROM  profile_binets\n                            WHERE  pid = {?}", $page->pid());
     if (!count($value)) {
         return;
     }
     $insert = array();
     foreach ($value as $id => $text) {
         $insert[] = XDB::format('({?}, {?})', $page->pid(), $id);
     }
     XDB::execute("INSERT INTO  profile_binets (pid, binet_id)\n                           VALUES  " . implode(',', $insert));
 }
예제 #9
0
function fix_homonym(PlUser $user, $email)
{
    XDB::execute('DELETE FROM  email_source_account
                        WHERE  email = {?} AND type = \'alias\'', $email);
    $hrmid = User::makeHomonymHrmid($email);
    // TODO: insert twice into source_other if different domains
    XDB::execute('INSERT INTO  email_source_other (hrmid, email, domain, type, expire)
                       SELECT  {?}, {?}, id, \'homonym\', NOW()
                         FROM  email_virtual_domains
                        WHERE  name = {?}', $hrmid, $email, $user->mainEmailDomain());
    XDB::execute("INSERT INTO  email_redirect_other (hrmid, redirect, type, action)\n                       VALUES  ({?}, '', 'homonym', 'homonym')", $hrmid);
    require_once 'emails.inc.php';
    fix_bestalias($user);
}
예제 #10
0
파일: geocoder.php 프로젝트: Ekleog/platal
 public static function getComponentId(array $component)
 {
     $where = '';
     foreach ($component['types'] as $type) {
         $where .= XDB::format(' AND FIND_IN_SET({?}, types)', $type);
     }
     $id = XDB::fetchOneCell('SELECT  id
                                FROM  profile_addresses_components_enum
                               WHERE  short_name = {?} AND long_name = {?}' . $where, $component['short_name'], $component['long_name']);
     if (is_null($id)) {
         XDB::execute('INSERT INTO  profile_addresses_components_enum (short_name, long_name, types)
                            VALUES  ({?}, {?}, {?})', $component['short_name'], $component['long_name'], implode(',', $component['types']));
         $id = XDB::insertId();
     }
     return $id;
 }
예제 #11
0
 protected function _saveData()
 {
     if ($this->changed['message']) {
         $message = trim($this->values['message']);
         if (empty($message)) {
             XDB::execute('DELETE FROM  profile_deltaten
                                 WHERE  pid = {?}', $this->pid());
             $this->values['message'] = null;
         } else {
             XDB::execute('INSERT INTO  profile_deltaten (pid, message)
                                VALUES  ({?}, {?})
               ON DUPLICATE KEY UPDATE  message = VALUES(message)', $this->pid(), $message);
             $this->values['message'] = $message;
         }
     }
 }
예제 #12
0
 public function commit()
 {
     global $globals;
     $email = $this->m_user->bestEmail();
     XDB::execute('UPDATE  email_redirect_account
                      SET  flags = \'active\', broken_level = 2
                    WHERE  uid = {?} AND redirect = {?}', $this->m_user->id(), $this->m_email);
     if (XDB::affectedRows() > 0) {
         $this->m_reactive = true;
         $mailer = new PlMailer();
         $mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>');
         $mailer->addTo($email);
         $mailer->setSubject("Mise à jour de ton adresse {$email}");
         $mailer->setTxtBody(wordwrap("Cher Camarade,\n\n" . "Ton adresse {$email} étant en panne et ayant été informés que ta redirection {$this->m_email}, jusqu'à présent inactive, " . "est fonctionnelle, nous venons de réactiver cette adresse.\n\n" . "N'hésite pas à aller gérer toi-même tes redirections en te rendant à la page :\n" . "https://www.polytechnique.org/emails/redirect\n" . "Si tu as perdu ton mot de passe d'accès au site, tu peux également effectuer la procédure de récupération à l'adresse :\n" . "https://www.polytechnique.org/recovery\n\n" . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n"));
         $mailer->send();
         return true;
     }
     if ($this->m_user->email) {
         $subject = "Ton adresse {$email} semble ne plus fonctionner";
         $reason = "Nous avons été informés que ton adresse {$email} ne fonctionne plus correctement par un camarade";
     } else {
         $res = XDB::iterRow('SELECT  redirect
                                FROM  email_redirect_account
                               WHERE  uid = {?} AND flags = \'broken\'', $this->m_user->id());
         $redirect = array();
         while (list($red) = $res->next()) {
             list(, $redirect[]) = explode('@', $red);
         }
         $subject = "Ton adresse {$email} ne fonctionne plus";
         $reason = "Ton adresse {$email} ne fonctionne plus";
         if (!count($redirect)) {
             $reason .= '.';
         } elseif (count($redirect) == 1) {
             $reason .= ' car sa redirection vers ' . $redirect[0] . ' est hors-service depuis plusieurs mois.';
         } else {
             $reason .= ' car ses redirections vers ' . implode(', ', $redirect) . ' sont hors-services depuis plusieurs mois.';
         }
     }
     $body = ($this->m_user->isFemale() ? 'Chère ' : 'Cher ') . $this->m_user->displayName() . ",\n\n" . $reason . "\n\n" . "L'adresse {$this->m_email} nous a été communiquée, veux-tu que cette adresse devienne ta nouvelle " . "adresse de redirection ? Si oui, envoie nous des informations qui " . "nous permettront de nous assurer de ton identité (par exemple ta date de naissance et ta promotion).\n\n" . "-- \nTrès Cordialement,\nL'Équipe de Polytechnique.org\n";
     $body = wordwrap($body, 78);
     $mailer = new PlMailer();
     $mailer->setFrom('"Association Polytechnique.org" <register@' . $globals->mail->domain . '>');
     $mailer->addTo($this->m_email);
     $mailer->setSubject($subject);
     $mailer->setTxtBody($body);
     return $mailer->send();
 }
예제 #13
0
 function handler_admin_url($page)
 {
     $page->changeTpl('urlshortener/admin.tpl');
     if (!Post::has('url')) {
         return;
     }
     $url = Post::t('url');
     $alias = Post::t('alias');
     $url_regex = '{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i';
     if (strlen($url) > 255 || !preg_match($url_regex, $url)) {
         $page->trigError("L'url donnée n'est pas valide.");
         return;
     }
     $page->assign('url', $url);
     if ($alias != '') {
         if (!preg_match('/^[a-zA-Z0-9\\-\\/]+$/i', $alias)) {
             $page->trigError("L'alias proposé n'est pas valide.");
             return;
         }
         if (preg_match('/^a\\//i', $alias)) {
             $page->trigError("L'alias commence par le préfixe 'a/' qui est réservé et donc non autorisé.");
             return;
         }
         $page->assign('alias', $alias);
         $used = XDB::fetchOneCell('SELECT  COUNT(*)
                                      FROM  url_shortener
                                     WHERE  alias = {?}', $alias);
         if ($used != 0) {
             $page->trigError("L'alias proposé est déjà utilisé.");
             return;
         }
     } else {
         do {
             $alias = 'a/' . rand_token(6);
             $used = XDB::fetchOneCell('SELECT  COUNT(*)
                                          FROM  url_shortener
                                         WHERE  alias = {?}', $alias);
         } while ($used != 0);
         $page->assign('alias', $alias);
     }
     XDB::execute('INSERT INTO  url_shortener (url, alias)
                        VALUES  ({?}, {?})', $url, $alias);
     $page->trigSuccess("L'url « " . $url . ' » est maintenant accessible depuis « http://u.w4x.org/' . $alias . ' ».');
 }
예제 #14
0
 public function HandleAction($action)
 {
     $user = S::user();
     switch ($action) {
         case 'yes':
             XDB::execute('INSERT IGNORE INTO  group_members (uid, asso_id)
                                   SELECT  {?}, id
                                     FROM  groups
                                    WHERE  diminutif = {?}', $user->id(), $user->profile()->yearPromo());
             MailingList::subscribePromo($user->profile()->yearPromo());
             $this->UpdateOnYes();
             break;
         case 'dismiss':
             $this->UpdateOnDismiss();
             break;
         case 'no':
             $this->UpdateOnNo();
             break;
     }
 }
예제 #15
0
파일: names.php 프로젝트: Ekleog/platal
function update_private($data, $string, $pid, &$aliases, $perform_updates)
{
    // We here assume there are no other last/firstnames as there do not seem to be any in the db.
    $string = substr($string, 1, strlen($string) - 2);
    $string = substr($string, 6, strlen($string) - 6);
    if (!isset($aliases[$pid])) {
        if ($perform_updates) {
            XDB::execute("INSERT INTO  profile_private_names (pid, type, id, name)\n                               VALUES  ({?}, 'nickname', 0, {?})", $pid, $string);
        } else {
            print $string . ' (alias for pid ' . $pid . ")\n";
        }
    } elseif ($aliases[$pid] != $string) {
        if ($perform_updates) {
            XDB::execute('UPDATE  profile_private_names
                             SET  name = {?}
                           WHERE  pid = {?} AND name = {?}', $string, $pid, $aliases[$pid]);
        } else {
            print $string . ' (new alias for pid ' . $pid . ' replacing ' . $aliases[$pid] . ")\n";
        }
    }
}
예제 #16
0
function associate_room_ip($rid, $ip, $comment)
{
    global $ips2room, $ips2roomUnkown;
    global $execute_real;
    if (empty($ips2room[$ip])) {
        echo "IP " . $ip . " is not yet associated with room " . $rid . " (" . $comment . ")\n";
        if ($execute_real) {
            XDB::execute('INSERT INTO ips SET ip = {?}, rid = {?}, comment = {?}', $ip, $rid, $comment);
            echo "... Inserted.\n";
        }
    } else {
        unset($ips2roomUnkown[$ip]);
        if ($ips2room[$ip]['r'] != $rid) {
            echo "IP " . $ip . " is associated with room " . $ips2room[$ip]['r'] . " (" . $ips2room[$ip]['c'] . ") instead of " . $rid . " (" . $comment . ")\n";
            if ($execute_real) {
                XDB::execute('UPDATE ips SET rid = {?}, comment = {?} WHERE ip = {?}', $rid, $comment, $ip);
                echo "... Changed.\n";
            }
        }
    }
}
예제 #17
0
파일: xnetnl.php 프로젝트: Ekleog/platal
 public function handler_admin_nl_enable($page)
 {
     global $globals;
     $nl = $this->getNl();
     if ($nl) {
         return PL_FORBIDDEN;
     }
     if (Post::has('title')) {
         if (!S::has_xsrf_token()) {
             return PL_FORBIDDEN;
         }
         XDB::execute('INSERT INTO  newsletters
                               SET  group_id = {?}, name = {?}', $globals->asso('id'), Post::s('title'));
         $mailer = new PlMailer();
         $mailer->assign('group', $globals->asso('nom'));
         $mailer->assign('user', S::user());
         $mailer->send();
         $page->trigSuccessRedirect("La lettre d'informations du groupe " . $globals->asso('nom') . " a bien été créée", $globals->asso('shortname') . '/admin/nl');
     }
     $page->setTitle('Activation de la newsletter');
     $page->changeTpl('newsletter/enable.tpl');
 }
예제 #18
0
#!/usr/bin/php5
<?php 
require_once 'connect.db.inc.php';
// Fetches the list of unregistered users.
$users = XDB::iterRow("SELECT  user_id, prenom, nom, promo\n       FROM  auth_user_md5\n      WHERE  hruid IS NULL");
// Creates missing human readable uids.
while (list($user_id, $prenom, $nom, $promo) = $users->next()) {
    $forlife = make_forlife($prenom, $nom, $promo);
    $hruid = XDB::query('SELECT * FROM auth_user_md5 WHERE hruid = {?} AND user_id != {?}', $forlife, $user_id);
    if ($hruid->numRows() > 0) {
        echo "WARNING: Duplicate forlife for user {$user_id} and forlife '{$forlife}'. Please check manually the entry.\n";
    } else {
        XDB::execute('UPDATE auth_user_md5 SET hruid = {?} WHERE user_id = {?}', $forlife, $user_id);
    }
}
예제 #19
0
$res = XDB::query('SELECT  id, target, writer, writername, title, body, ishtml
                     FROM  mails
                    WHERE  processed IS NULL')->fetchAllRow();
$ids = array();
if (count($res) == 0) {
    exit;
}
foreach ($res as $r) {
    $ids[] = $r[0];
}
XDB::execute('UPDATE  mails
                 SET  processed = NOW()
               WHERE  id IN {?}', $ids);
XDB::commit();
foreach ($res as $r) {
    $uf = new UserFilter($r[1]);
    $users = $uf->get();
    $users->select(UserSelect::base());
    foreach ($users as $user) {
        $mail = new FrankizMailer();
        $mail->addAddress($user->bestEmail(), $user->fullName());
        $mail->SetFrom($r[2], $r[3]);
        $mail->subject($r[4]);
        $mail->body($r[5]);
        $mail->send($r[6]);
    }
    XDB::execute('UPDATE  mails
                     SET  done = NOW()
                   WHERE  id = {?}', $r[0]);
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
예제 #20
0
 /** Deletes request from 'requests' table.
  * If $this->unique is set, it deletes every requests of this type.
  */
 public function clean()
 {
     global $globals;
     if ($this->unique) {
         $success = XDB::execute('DELETE FROM  requests
                                        WHERE  pid = {?} AND type = {?}', $this->profile->id(), $this->type);
     } else {
         $success = XDB::execute('DELETE FROM  requests
                                         WHERE  pid = {?} AND type = {?} AND stamp = {?}', $this->profile->id(), $this->type, $this->stamp);
     }
     $globals->updateNbValid();
     return $success;
 }
예제 #21
0
파일: compare.php 프로젝트: netixx/frankiz
    } catch (Exception $e) {
    }
    XDB::execute('CREATE DATABASE compare DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci');
    XDB::execute('USE compare');
    $tables = glob("2.0.0_to_3.0.0/sql/*.sql");
    sort($tables);
    foreach ($tables as $table) {
        echo exec('mysql -h ' . $globals->dbhost . ' -u ' . $globals->dbuser . ' -p' . $globals->dbpwd . ' compare < ' . $table);
    }
    echo "Comparing actual DB '{$dba}' with the theoritical one \n";
}
// Fetch the tables names from the DBs
XDB::execute("USE {$dba}");
$a_tables = XDB::query('SHOW TABLES');
$a_tables = $a_tables->fetchColumn();
XDB::execute("USE {$dbb}");
$b_tables = XDB::query('SHOW TABLES');
$b_tables = $b_tables->fetchColumn();
// Compare the tables
$tables = array();
foreach ($b_tables as $table) {
    if (!in_array($table, $a_tables)) {
        $tables[$table] = 'missing';
    } else {
        $theoric = XDB::query('DESCRIBE ' . $table)->fetchAllAssoc('Field');
        $actual = XDB::query('DESCRIBE ' . $globals->dbdb . '.' . $table)->fetchAllAssoc('Field');
        foreach ($theoric as $field => $infos) {
            if (!array_key_exists($field, $actual)) {
                $tables[$table][] = "- '{$field}' " . $infos['Type'] . "";
            } else {
                if ($infos['Type'] != $actual[$field]['Type']) {
예제 #22
0
function event_change_shortname($page, $eid, $old, $new)
{
    global $globals;
    require_once 'emails.inc.php';
    if (is_null($old)) {
        $old = '';
    }
    // Quelques vérifications sur l'alias (caractères spéciaux)
    if ($new && !preg_match("/^[a-zA-Z0-9\\-.]{3,20}\$/", $new)) {
        $page->trigError("Le raccourci demandé n'est pas valide.\n                    Vérifie qu'il comporte entre 3 et 20 caractères\n                    et qu'il ne contient que des lettres non accentuées,\n                    des chiffres ou les caractères - et .");
        return $old;
    } elseif ($new && (is_int($new) || ctype_digit($new))) {
        $page->trigError("Le raccourci demandé ne peut être accepté car il\n                         ne contient que des chiffres. Rajoute-lui par exemple\n                         une lettre.");
        return $old;
    }
    //vérifier que l'alias n'est pas déja pris
    if ($new && $old != $new) {
        $res = XDB::query('SELECT COUNT(*)
                             FROM group_events
                            WHERE short_name = {?}', $new);
        if ($res->fetchOneCell() > 0) {
            $page->trigError("Le raccourci demandé est déjà utilisé. Choisis en un autre.");
            return $old;
        }
    }
    if ($old == $new) {
        return $new;
    }
    if ($old && $new) {
        // if had a previous shortname change the old lists
        foreach (explode(',', $globals->xnet->event_lists) as $suffix) {
            XDB::execute('UPDATE  email_virtual
                             SET  email = {?}
                           WHERE  type = \'event\' AND email = {?}', $new . $suffix, $old . $suffix);
        }
        return $new;
    }
    if (!$old && $new) {
        // if we have a first new short_name create the lists
        $lastid = array();
        $where = array($globals->xnet->participant_list => 'g.nb > 0', $globals->xnet->payed_list => '(g.paid > 0 OR p.amount > 0)', $globals->xnet->unpayed_list => 'g.nb > 0 AND g.paid = 0 AND p.amount IS NULL');
        foreach (array($globals->xnet->participant_list, $globals->xnet->payed_list, $globals->xnet->unpayed_list) as $suffix) {
            $uids = XDB::fetchColumn('SELECT  g.uid
                                        FROM  group_event_participants AS g
                                  INNER JOIN  group_events             AS e ON (g.eid = e.eid)
                                   LEFT JOIN  payment_transactions     AS p ON (e.paiement_id = p.ref AND g.uid = p.uid)
                                       WHERE  g.eid = {?} AND ' . $where[$suffix], $eid);
            foreach ($uids as $uid) {
                add_to_list_alias($uid, $new . $suffix, $globals->xnet->evts_domain, 'event');
            }
        }
        $uids = XDB::fetchColumn('SELECT  m.uid
                                    FROM  group_members            AS m
                               LEFT JOIN  group_event_participants AS e ON (e.uid = m.uid AND e.eid = {?})
                                   WHERE  m.asso_id = {?} AND e.uid IS NULL', $eid, $globals->asso('id'));
        foreach ($uids as $uid) {
            add_to_list_alias($uid, $new . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
        }
        return $new;
    }
    if ($old && !$new) {
        // if we delete the old short name, delete the lists
        foreach (explode(',', $globals->xnet->event_lists) as $suffix) {
            delete_list_alias($old . $suffix, $globals->xnet->evts_domain);
        }
        return $new;
    }
    // cannot happen
    return $old;
}
예제 #23
0
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 ***************************************************************************/
require_once 'connect.db.inc.php';
require_once 'plmailer.php';
require_once 'notifs.inc.php';
ini_set('memory_limit', '128M');
$uids = XDB::query('SELECT  uid
                      FROM  watch
                     WHERE  FIND_IN_SET(\'mail\', flags)
                  ORDER BY  uid');
$iterator = User::iterOverUIDs($uids->fetchColumn());
while ($user = $iterator->next()) {
    $watch = new Watch($user);
    if ($watch->count() > 0) {
        $notifs = $watch->events();
        $mailer = new PlMailer('carnet/notif.mail.tpl');
        $mailer->assign('sex', $user->isFemale());
        $mailer->assign('yourself', $user->display_name);
        $mailer->assign('week', date('W - Y'));
        $mailer->assign('notifs', $notifs);
        $mailer->sendTo($user);
        unset($mailer);
        unset($notifs);
    }
    unset($watch);
    unset($user);
}
XDB::execute("UPDATE  watch_profile\n                 SET  ts = NOW()\n               WHERE  field = 'broken'");
XDB::execute('DELETE FROM  watch_profile
                    WHERE  ts < DATE_SUB(CURRENT_DATE, INTERVAL 15 DAY)');
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
예제 #24
0
파일: validate.php 프로젝트: netixx/frankiz
 /** 
  * to clean an entry
  * must have an item
  */
 public function clean()
 {
     if ($this->item->unique()) {
         $success = XDB::execute('DELETE FROM  validate
                                        WHERE  writer = {?} AND `group` = {?} AND type = {?}', $this->writer->id(), $this->group->id(), $this->type);
     } else {
         $success = XDB::execute('DELETE FROM  validate
                                         WHERE  id = {?}', $this->id);
     }
     return $success;
 }
예제 #25
0
    while ($values = $res->next()) {
        if ($values['pid'] != $pid) {
            $mailer = new PlMailer('profile/notification.mail.tpl');
            $mailer->addTo($user);
            $mailer->assign('modifications', $modifications);
            $mailer->assign('yourself', $yourself);
            $mailer->assign('hrpid', $hrpid);
            $mailer->assign('sex', $sex);
            $mailer->assign('date', $date);
            $mailer->send();
            $modifications = array();
        }
        $pid = $values['pid'];
        $sex = $values['sex'] == 'female' ? 1 : 0;
        $yourself = $values['yourself'];
        $user = User::getSilentWithUID($values['uid']);
        $hrpid = $values['hrpid'];
        $modifications[] = array('full_name' => $values['full_name'], 'field' => $values['field'], 'oldText' => $values['oldText'], 'newText' => $values['newText']);
    }
    $mailer = new PlMailer('profile/notification.mail.tpl');
    $mailer->addTo($user);
    $mailer->assign('modifications', $modifications);
    $mailer->assign('yourself', $yourself);
    $mailer->assign('hrpid', $hrpid);
    $mailer->assign('sex', $sex);
    $mailer->assign('date', $date);
    $mailer->send();
    XDB::execute('DELETE FROM  profile_modifications
                        WHERE  type = \'third_party\'');
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
예제 #26
0
foreach ($tables as $table => $keys) {
    $res = XDB::query("SELECT * FROM geoloc_{$table}");
    if (!$res) {
        echo "{$table}\n";
        continue;
    }
    $all = $res->fetchAllAssoc();
    foreach ($all as &$array) {
        $from = array();
        $to = array();
        foreach ($array as $key => $value) {
            if (in_array($key, $keys)) {
                $from[] = $key . '=' . XDB::escape($value);
            }
            $valued = utf8_decode($value);
            if (is_utf8($value) && $valued != $value) {
                $to[] = $key . '=' . XDB::escape($valued);
            }
        }
        if (!empty($to)) {
            $to = implode(', ', $to);
            $from = implode(' AND ', $from);
            $sql = "UPDATE geoloc_{$table} SET {$to} WHERE {$from}";
            if (!XDB::execute($sql)) {
                echo "Echec : {$sql}\n";
            } elseif (XDB::affectedRows() == 0) {
                echo "{$sql}\n";
            }
        }
    }
}
예제 #27
0
 private static function UpdateStatus($uid, $type_id, $status, $next_ask)
 {
     XDB::execute('INSERT INTO  reminder (uid, type_id, status, remind_last, remind_next)
                        VALUES  ({?}, {?}, {?}, NOW(), FROM_UNIXTIME({?}))
       ON DUPLICATE KEY UPDATE  status = VALUES(status), remind_last = VALUES(remind_last), remind_next = VALUES(remind_next)', $uid, $type_id, $status, $next_ask > 0 ? time() + $next_ask * 24 * 60 * 60 : null);
 }
예제 #28
0
#!/usr/bin/php5
<?php 
global $globals;
require_once 'connect.db.inc.php';
// Fetches the list of existing xnetevents aliases.
$events = XDB::iterRow("SELECT  e.eid, e.asso_id, e.short_name, al.vid, pl.vid\n       FROM  groupex.evenements AS e\n  LEFT JOIN  virtual AS al ON (al.type = 'evt' AND al.alias = CONCAT(short_name, {?}))\n  LEFT JOIN  virtual AS pl ON (pl.type = 'evt' AND pl.alias = CONCAT(short_name, {?}))\n      WHERE  al.vid IS NOT NULL AND pl.vid IS NOT NULL\n   ORDER BY  e.eid", '-absents@' . $globals->xnet->evts_domain, '-participants@' . $globals->xnet->evts_domain);
// Fixes the alias recipients for each list.
while (list($eid, $asso_id, $shortname, $absent_vid, $participant_vid) = $events->next()) {
    $recipient_count = array();
    foreach (array($absent_vid, $participant_vid) as $vid) {
        $res = XDB::query("SELECT COUNT(*) FROM  virtual_redirect WHERE vid = {?}", $vid);
        $recipient_count[$vid] = $res->fetchOneCell();
    }
    // Updates the alias for participants.
    XDB::execute("DELETE FROM virtual_redirect WHERE vid = {?}", $participant_vid);
    XDB::execute("INSERT INTO  virtual_redirect (\n              SELECT  {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect\n                FROM  groupex.evenements_participants AS ep\n           LEFT JOIN  groupex.membres AS m ON (ep.uid = m.uid)\n           LEFT JOIN  auth_user_md5   AS u ON (u.user_id = ep.uid)\n           LEFT JOIN  aliases         AS a ON (a.id = ep.uid AND a.type = 'a_vie')\n               WHERE  ep.eid = {?} AND ep.nb > 0\n            GROUP BY  ep.uid)", $participant_vid, '@' . $globals->mail->domain, $eid);
    // Updates the alias for absents.
    XDB::execute("DELETE FROM virtual_redirect WHERE vid = {?}", $absent_vid);
    XDB::execute("INSERT INTO  virtual_redirect (\n              SELECT  {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect\n                FROM  groupex.membres AS m\n           LEFT JOIN  groupex.evenements_participants AS ep ON (ep.uid = m.uid AND ep.eid = {?})\n           LEFT JOIN  auth_user_md5   AS u ON (u.user_id = m.uid)\n           LEFT JOIN  aliases         AS a ON (a.id = m.uid AND a.type = 'a_vie')\n               WHERE  m.asso_id = {?} AND ep.uid IS NULL\n            GROUP BY  m.uid)", $absent_vid, "@" . $globals->mail->domain, $eid, $asso_id);
    // Lists alias recipient count changes.
    $new_recipient_count = array();
    foreach (array($absent_vid, $participant_vid) as $vid) {
        $res = XDB::query("SELECT COUNT(*) FROM  virtual_redirect WHERE vid = {?}", $vid);
        $new_recipient_count[$vid] = $res->fetchOneCell();
    }
    if ($new_recipient_count[$absent_vid] != $recipient_count[$absent_vid] || $new_recipient_count[$participant_vid] != $recipient_count[$participant_vid]) {
        printf("  Fixed aliases for event %d (%s): absent list %d -> %d, participant list %d -> %d\n", $eid, $shortname, $recipient_count[$absent_vid], $new_recipient_count[$absent_vid], $recipient_count[$participant_vid], $new_recipient_count[$participant_vid]);
    }
}
예제 #29
0
 public function commit()
 {
     XDB::execute('INSERT INTO  profile_photos (pid, attachmime, attach, x, y)
                        VALUES  ({?}, {?}, {?}, {?}, {?})
       ON DUPLICATE KEY UPDATE  attachmime = VALUES(attachmime), attach = VALUES(attach),
                                x = VALUES(x), y = VALUES(y)', $this->profile->id(), $this->mimetype, $this->data, $this->x, $this->y);
     return true;
 }
예제 #30
0
파일: qdj.php 프로젝트: netixx/frankiz
 public function vote($answer)
 {
     XDB::startTransaction();
     XDB::execute('INSERT INTO  qdj_votes
                           SET  qdj = {?}, uid = {?}, rank = 0, rule = "null"', $this->id(), S::user()->id());
     $vote = XDB::insertID();
     // Get the rank
     $rank = XDB::query('SELECT  COUNT(*)+1
                           FROM  qdj_votes
                          WHERE  qdj = {?} AND rank != 0', $this->id())->fetchOneCell();
     if ($rank == 1) {
         if ($this->writer === null) {
             $this->select(QDJSelect::all());
         }
         XDB::execute('INSERT INTO  qdj_votes
                               SET  qdj = {?}, uid = {?}, rank = 0, rule = 10', $this->id(), $this->writer->id());
     }
     $rule = null;
     switch ($rank) {
         case 1:
             $rule = '1';
             break;
         case 2:
             $rule = '2';
             break;
         case 3:
             $rule = '3';
             break;
         case 13:
             $rule = '4';
             break;
         case 42:
             $rule = '5';
             break;
         case 69:
             $rule = '6';
             break;
         case 314:
             $rule = '7';
             break;
         case substr(strrchr(IPAddress::get(), '.'), 1):
             $rule = '8';
             break;
         case date('d') + date('m'):
             $rule = '9';
             break;
     }
     XDB::execute('UPDATE qdj_votes
                      SET rank = {?}, rule = {?}
                    WHERE vote_id = {?}', $rank, $rule, $vote);
     XDB::commit();
     if ($answer == 1) {
         XDB::execute('UPDATE qdj SET count1 = count1+1 WHERE id={?}', $this->id());
     } else {
         XDB::execute('UPDATE qdj SET count2 = count2+1 WHERE id={?}', $this->id());
     }
 }