예제 #1
0
 public function update_membernum($fid, $num = 1)
 {
     if (!intval($fid) || !intval($num)) {
         return false;
     }
     XDB::query("UPDATE %t SET membernum=membernum+%d WHERE fid=%d", array('forum_forumfield', $num, $fid));
 }
예제 #2
0
 public static function IsCandidate(User $user, $candidate)
 {
     $profile = $user->profile();
     if (!$profile) {
         return false;
     }
     // We only test if the user is in her promotion group for it is too
     // expensive to check if she is in the corresponding ML as well.
     $res = XDB::query('SELECT  COUNT(*)
                          FROM  group_members
                         WHERE  uid = {?} AND asso_id = (SELECT  id
                                                           FROM  groups
                                                          WHERE  diminutif = {?})', $user->id(), $user->profile()->yearPromo());
     $mlCount = $res->fetchOneCell();
     if ($mlCount) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     if ($mlCount == 0) {
         $mlist = MailingList::promo($user->profile()->yearPromo());
         try {
             $mlist->getMembersLimit(0, 0);
         } catch (Exception $e) {
             return false;
         }
     }
     return false;
 }
예제 #3
0
 function prepareform($pay, $user)
 {
     // Documentation:
     // https://www.paypal.com/developer
     // Warning: the automatic return only works if we force the
     // users to create a paypal account. We do not use it; thus
     // the user must come back on the site.
     global $globals, $platal;
     $this->urlform = 'https://' . $globals->money->paypal_site . '/cgi-bin/webscr';
     $roboturl = str_replace("https://", "http://", $globals->baseurl) . '/' . $platal->ns . "payment/paypal_return/" . $user->id() . "?comment=" . urlencode(Env::v('comment')) . '&display=' . Post::i('display');
     $this->infos = array('commercant' => array('business' => $globals->money->paypal_compte, 'rm' => 2, 'return' => $roboturl, 'cn' => 'Commentaires', 'no_shipping' => 1, 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ? 'Revenir sur polytechnique.org.' : 'Revenir sur polytechnique.net.'));
     $info_client = array('first_name' => $user->firstName(), 'last_name' => $user->lastName(), 'email' => $user->bestEmail());
     if ($user->hasProfile()) {
         $res = XDB::query("SELECT  pa.text, GROUP_CONCAT(pace2.short_name) AS city,\n                                       GROUP_CONCAT(pace3.short_name) AS zip, GROUP_CONCAT(pace1.short_name) AS country,\n                                       IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b\n                                 FROM  profile_addresses                 AS pa\n                            LEFT JOIN  profile_phones                    AS pp1   ON (pp1.pid = pa.pid AND pp1.link_type = 'address' AND pp1.link_id = pa.id)\n                            LEFT JOIN  profile_phones                    AS pp2   ON (pp2.pid = pa.pid AND pp2.link_type = 'user' AND pp2.link_id = 0)\n                            LEFT JOIN  profile_addresses_components      AS pc    ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid\n                                                                                      AND pa.type = pc.type AND pa.id = pc.id)\n                            LEFT JOIN  profile_addresses_components_enum AS pace1 ON (FIND_IN_SET('country', pace1.types) AND pace1.id = pc.component_id)\n                            LEFT JOIN  profile_addresses_components_enum AS pace2 ON (FIND_IN_SET('locality', pace2.types) AND pace2.id = pc.component_id)\n                            LEFT JOIN  profile_addresses_components_enum AS pace3 ON (FIND_IN_SET('postal_code', pace3.types) AND pace3.id = pc.component_id)\n                                WHERE  pa.pid = {?} AND FIND_IN_SET('current', pa.flags)\n                             GROUP BY  pa.pid, pa.jobid, pa.groupid, pa.id, pa.type\n                                LIMIT  1", $user->profile()->id());
         if (is_array($res)) {
             $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
             list($this->infos['client']['address1'], $this->infos['client']['address2']) = explode("\n", Geocoder::getFirstLines($this->infos['client']['text'], $this->infos['client']['zip'], 2));
             unset($this->infos['client']['text']);
         } else {
             $this->infos['client'] = array_map('replace_accent', $info_client);
         }
     } else {
         $this->infos['client'] = array_map('replace_accent', $info_client);
     }
     // We build the transaction's reference
     $prefix = rand_url_id();
     $fullref = substr("{$prefix}-xorg-{$pay->id}", -15);
     $this->infos['commande'] = array('item_name' => replace_accent($pay->text), 'amount' => $this->val_number, 'currency_code' => 'EUR', 'custom' => $fullref);
     $this->infos['divers'] = array('cmd' => '_xclick');
 }
예제 #4
0
파일: ml.inc.php 프로젝트: Ekleog/platal
 public function run()
 {
     global $platal, $globals;
     $nom = S::v('prenom') . ' ' . S::v('nom');
     $mail = $this->user->bestEmail();
     $sig = $nom . ' (' . S::v('promo') . ')';
     Banana::$msgedit_headers['X-Org-Mail'] = $this->user->forlifeEmail();
     // Tree color
     $req = XDB::query('SELECT  tree_unread, tree_read
                          FROM  forum_profiles
                         WHERE  uid= {?}', $this->user->id());
     if (!(list($unread, $read) = $req->fetchOneRow())) {
         $unread = 'o';
         $read = 'dg';
     }
     Banana::$tree_unread = $unread;
     Banana::$tree_read = $read;
     // Build user profile
     Banana::$profile['headers']['From'] = "{$nom} <{$mail}>";
     Banana::$profile['headers']['Organization'] = make_Organization();
     Banana::$profile['signature'] = $sig;
     // Page design
     Banana::$page->killPage('forums');
     Banana::$page->killPage('subscribe');
     // Run Banana
     return parent::run();
 }
예제 #5
0
 protected function _fetchData()
 {
     $res = XDB::query('SELECT  message
                          FROM  profile_deltaten
                         WHERE  pid = {?}', $this->pid());
     $this->values['message'] = $res->fetchOneCell();
 }
예제 #6
0
파일: days.php 프로젝트: netixx/frankiz
 public function run()
 {
     $today = date('d');
     $month = date('m');
     $res = XDB::query("\n                SELECT name\n                FROM days\n                WHERE day={$today} AND month={$month}\n                ");
     $fetes = $res->fetchColumn(0);
     $this->assign("fetes", $fetes);
 }
예제 #7
0
/**
 * Checks for sessions without a valid associated user id.
 */
function checkOrphanedSessions()
{
    $begin = time();
    $res = XDB::query("SELECT  COUNT(*)\n           FROM  log_sessions     AS s\n      LEFT JOIN  #x5dat#.accounts AS a ON (a.uid = s.uid)\n          WHERE  a.uid IS NULL");
    if ($count = $res->fetchOneCell()) {
        $duration = time() - $begin;
        echo "Orphaned sessions: found {$count} orphaned sessions in {$duration} seconds. Please fix that.\n";
    }
}
예제 #8
0
 public function value(ProfilePage $page, $field, $value, &$success)
 {
     $success = true;
     if (is_null($value)) {
         $res = XDB::query("SELECT  section\n                                 FROM  profiles\n                                WHERE  pid = {?}", $page->pid());
         return intval($res->fetchOneCell());
     }
     return intval($value);
 }
예제 #9
0
파일: addresses.php 프로젝트: Ekleog/platal
function get_address_text($adr)
{
    $t = '';
    if (isset($adr['adr1']) && $adr['adr1']) {
        $t .= $adr['adr1'];
    }
    if (isset($adr['adr2']) && $adr['adr2']) {
        $t .= "\n" . $adr['adr2'];
    }
    if (isset($adr['adr3']) && $adr['adr3']) {
        $t .= "\n" . $adr['adr3'];
    }
    $l = '';
    if (isset($adr['display']) && $adr['display']) {
        $keys = explode(' ', $adr['display']);
        foreach ($keys as $key) {
            if (isset($adr[$key])) {
                $l .= ' ' . $adr[$key];
            } else {
                $l .= ' ' . $key;
            }
        }
        if ($l) {
            substr($l, 1);
        }
    } elseif ($adr['country'] == 'US' || $adr['country'] == 'CA' || $adr['country'] == 'GB') {
        if ($adr['city']) {
            $l .= $adr['city'] . ",\n";
        }
        if ($adr['region']) {
            $l .= $adr['region'] . ' ';
        }
        if ($adr['postcode']) {
            $l .= $adr['postcode'];
        }
    } else {
        if (isset($adr['postcode']) && $adr['postcode']) {
            $l .= $adr['postcode'] . ' ';
        }
        if (isset($adr['city']) && $adr['city']) {
            $l .= $adr['city'];
        }
    }
    if ($l) {
        $t .= "\n" . trim($l);
    }
    if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) {
        $res = XDB::query('SELECT  countryFR
                             FROM  geoloc_countries
                            WHERE  iso_3166_1_a2 = {?}', $adr['country']);
        $adr['countrytxt'] = $res->fetchOneCell();
    }
    if (isset($adr['countrytxt']) && $adr['countrytxt']) {
        $t .= "\n" . $adr['countrytxt'];
    }
    return trim($t);
}
예제 #10
0
 public function __construct(User $_user, Profile $_profile, $_newGradYear)
 {
     parent::__construct($_user, $_profile, true, 'orange');
     $this->newGradYear = $_newGradYear;
     $res = XDB::query("SELECT  entry_year, grad_year\n                             FROM  profile_education\n                            WHERE  pid = {?} AND FIND_IN_SET('primary', flags)", $this->profile->id());
     $years = $res->fetchOneRow();
     $this->entryYear = $years[0];
     $this->oldGradYear = $years[1];
 }
예제 #11
0
파일: ml.inc.php 프로젝트: Ekleog/platal
 public static function IsCandidate(User $user, $candidate)
 {
     $res = XDB::query("SELECT  COUNT(*) AS lists\n                             FROM  register_subs\n                            WHERE  uid = {?} AND type = 'list'", $user->id());
     $mlCount = $res->fetchOneCell();
     if (!$mlCount) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     return $mlCount > 0;
 }
 public function update_num_by_catid($num, $catid, $numlimit = false)
 {
     $args = array($this->_table, $num, $catid);
     if ($numlimit !== false) {
         $sql = ' AND num>0';
         $args[] = $numlimit;
     }
     return XDB::query("UPDATE %t SET num=num+'%d' WHERE catid=%d {$sql}", $args);
 }
예제 #13
0
파일: todo.php 프로젝트: netixx/frankiz
 public function run()
 {
     $res = XDB::query('SELECT todo_id, sent, checked, tobedone
                        FROM todo
                       WHERE uid = {?}
                       ORDER BY sent DESC', S::user()->id());
     $array_todo = $res->fetchAllAssoc();
     $this->assign('list', $array_todo);
 }
예제 #14
0
 public function formu()
 {
     $res = XDB::query('SELECT  IF(MAX(m.last)>p.relance, MAX(m.last), p.relance)
                          FROM  accounts           AS a
                     LEFT JOIN  register_pending   AS p ON p.uid = a.uid
                     LEFT JOIN  register_marketing AS m ON m.uid = a.uid
                         WHERE  a.uid = {?}', $this->m_user->id());
     $this->m_relance = $res->fetchOneCell();
     return 'include/form.valid.mark.tpl';
 }
 public function update_all($data)
 {
     if (is_array($data)) {
         $update = array();
         foreach ($data as $key => $val) {
             $update[] = "`" . $key . "` = '" . $val . "'";
         }
         $setwhere = implode($update, ', ');
         XDB::query("UPDATE " . XDB::table($this->_table) . " SET " . $setwhere);
     }
 }
예제 #16
0
파일: lists.php 프로젝트: Ekleog/platal
 /** Fetch pending operations on a MailingList instance.
  */
 protected function get_pending_ops($mlist)
 {
     list($subs, $mails) = $mlist->getPendingOps();
     $res = XDB::query("SELECT  mid\n                             FROM  email_list_moderate\n                            WHERE  ml = {?} AND domain = {?}", $mlist->mbox, $mlist->domain);
     $mids = $res->fetchColumn();
     foreach ($mails as $key => $mail) {
         if (in_array($mail['id'], $mids)) {
             unset($mails[$key]);
         }
     }
     return array($subs, $mails);
 }
 public function clear()
 {
     require_once libfile('function/forum');
     $delaids = array();
     $query = XDB::query("SELECT aid, attachment, thumb FROM %t WHERE %i", array($this->_table, XDB::field('dateline', TIMESTAMP - 86400)));
     while ($attach = XDB::fetch($query)) {
         dunlink($attach);
         $delaids[] = $attach['aid'];
     }
     if ($delaids) {
         XDB::query("DELETE FROM %t WHERE %i", array('forum_attachment', XDB::field('aid', $delaids)), false, true);
         XDB::query("DELETE FROM %t WHERE %i", array($this->_table, XDB::field('dateline', TIMESTAMP - 86400)), false, true);
     }
 }
예제 #18
0
파일: gadgets.php 프로젝트: Ekleog/platal
 function handler_ig_events($page)
 {
     require_once 'gadgets/gadgets.inc.php';
     init_igoogle_html('gadgets/ig-events.tpl', AUTH_COOKIE);
     $events = XDB::iterator("SELECT  SQL_CALC_FOUND_ROWS\n                                         e.id, e.titre, UNIX_TIMESTAMP(e.creation_date) AS creation_date,\n                                         ev.uid IS NULL AS nonlu, e.uid\n                                   FROM  announces     AS e\n                              LEFT JOIN  announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?})\n                                  WHERE  FIND_IN_SET('valide', e.flags) AND expiration >= NOW()\n                               ORDER BY  e.creation_date DESC", S::i('uid'));
     $page->assign('event_count', XDB::query("SELECT FOUND_ROWS()")->fetchOneCell());
     Platal::load('events', 'feed.inc.php');
     $user = S::user();
     $data = array();
     while ($e = PlFeed::nextEvent($events, $user)) {
         $data[] = $e;
         if (count($data) == 5) {
             break;
         }
     }
     $page->assign('events', $data);
 }
예제 #19
0
function check_ip($level)
{
    if (empty($_SERVER['REMOTE_ADDR'])) {
        return false;
    }
    if (empty($_SESSION['check_ip'])) {
        $ips = array();
        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
        }
        $ips[] = $_SERVER['REMOTE_ADDR'];
        foreach ($ips as $key => $ip) {
            $v = ip_to_uint($ip);
            if (is_null($v)) {
                unset($ips[$key]);
            } else {
                $ips[$key] = '(ip & mask) = (' . $v . '& mask)';
            }
        }
        $res = XDB::query('SELECT  state, description
                             FROM  ip_watch
                            WHERE  ' . implode(' OR ', $ips) . '
                         ORDER BY  state DESC');
        if ($res->numRows()) {
            $state = $res->fetchOneAssoc();
            $_SESSION['check_ip'] = $state['state'];
            $_SESSION['check_ip_desc'] = $state['description'];
        } else {
            $_SESSION['check_ip'] = 'safe';
        }
    }
    $test = array();
    switch ($level) {
        case 'unsafe':
            $test[] = 'unsafe';
        case 'dangerous':
            $test[] = 'dangerous';
        case 'ban':
            $test[] = 'ban';
            break;
        default:
            return false;
    }
    return in_array($_SESSION['check_ip'], $test);
}
예제 #20
0
 public function updatestar_by_bid($uid, $username, $bid, $star = 1)
 {
     !in_array($star, array(1, 2, 3, 4, 5)) && ($star = 1);
     $hcount = C::t('#sanree_brand#sanree_brand_voterlog')->getvoter_by_bid_uid($uid, $bid);
     if ($hcount > 0) {
         return 0;
     }
     $data = array('uid' => $uid, 'username' => $username, 'bid' => $bid, 'star' => $star, 'dateline' => TIMESTAMP);
     C::t('#sanree_brand#sanree_brand_voterlog')->insert($data);
     $tcount = $this->getvoter_by_bid($bid);
     if ($tcount > 0) {
         XDB::query("UPDATE " . XDB::table($this->_table) . " SET `star" . $star . "`= star" . $star . " + 1 WHERE `bid`=" . $bid);
     } else {
         $mdata = array('uid' => $uid, 'bid' => $bid, 'star' . $star => 1, 'dateline' => TIMESTAMP);
         $this->insert($mdata);
     }
     return 1;
 }
예제 #21
0
 public function fetch_by_aid_uid($aid, $uid)
 {
     $query = XDB::query("SELECT * FROM %t WHERE aid=%d AND uid=%d", array($this->_table, $aid, $uid));
     return XDB::fetch($query);
 }
예제 #22
0
 function fetch_table_struct($tablename, $result = 'FIELD')
 {
     if (empty($tablename)) {
         return array();
     }
     $datas = array();
     $query = XDB::query("DESCRIBE " . XDB::table($tablename));
     while ($data = XDB::fetch($query)) {
         $datas[$data['Field']] = $result == 'FIELD' ? $data['Field'] : $data;
     }
     return $datas;
 }
예제 #23
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]);
    }
}
예제 #24
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);
    }
}
예제 #25
0
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program; if not, write to the Free Software            *
 *  Foundation, Inc.,                                                      *
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 ***************************************************************************/
/* This script send the mails waiting in the database */
require_once 'smarty/Smarty.class.php';
require_once dirname(__FILE__) . '/../connect.db.inc.php';
set_time_limit(0);
XDB::startTransaction();
$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();
예제 #26
0
function get_nouveau_infos($method, $params)
{
    global $error_mat, $error_key, $globals;
    // Password verification.
    if (!isset($params[0]) || $params[0] != $globals->manageurs->manageurs_pass) {
        return false;
    }
    // We check we actually have an identification number.
    if (!empty($params[1])) {
        $res = XDB::query("SELECT  ppn.lastname_initial AS nom, ppn.lastname_ordinary AS nom_usage, ppn.firstname_initial AS prenom,\n                                   p.sex = 'female' AS femme, p.deathdate IS NOT NULL AS decede,\n                                   p.birthdate, pd.promo, CONCAT(e.email, '@', d.name) AS mail\n                             FROM  profiles         AS p\n                       INNER JOIN  account_profiles AS ap ON (p.pid = ap.pid AND FIND_IN_SET('owner', perms)\n                       INNER JOIN  email_source_account AS s ON (s.uid = ap.uid AND FIND_IN_SET('bestalias', s.flags))\n                       INNER JOIN  email_virtual_domains AS d ON (s.domain = s.id)\n                       INNER JOIN  profile_display  AS pd PN (p.pid = pd.pid)\n                       INNER JOIN  profile_public_names AS ppn ON (ppn.pid = p.pid)\n                            WHERE  a.flags = 'bestalias' AND p.xorg_id = {?}", $params[1]);
        // $data['mail'] .= '@polytechnique.org';
        // We start the encryption of the data.
        if (manageurs_encrypt_init($params[1]) == 1) {
            // We did not find the key to encryptthe data.
            $args = array("erreur" => 3, "erreurstring" => $error_key);
            $reply = xmlrpc_encode_request(NULL, $args);
        } else {
            $reply = manageurs_encrypt_array($data);
            manageurs_encrypt_close();
        }
    } else {
        $reply = false;
    }
    return $reply;
}
예제 #27
0
/** Get membership informations for the current asso
 * @param force Force membership to be read from database
 * @param lose  Force membership to be false
 */
function is_member($force = false, $lose = false)
{
    if (!isset($_SESSION['is_member'])) {
        $_SESSION['is_member'] = array();
    }
    $is_member =& $_SESSION['is_member'];
    global $globals;
    $asso_id = $globals->asso('id');
    if (!$asso_id) {
        return false;
    } elseif ($lose) {
        $is_member[$asso_id] = false;
    } elseif (S::suid() && $force) {
        $is_member[$asso_id] = true;
    } elseif (!isset($is_member[$asso_id]) || $force) {
        $res = XDB::query("SELECT  COUNT(*)\n                             FROM  group_members\n                            WHERE  uid={?} AND asso_id={?}", S::v('uid'), $asso_id);
        $is_member[$asso_id] = $res->fetchOneCell() == 1;
    }
    return $is_member[$asso_id];
}
예제 #28
0
 /** Same as get_typed_requests() but returns the count of available requests.
  */
 public static function get_typed_requests_count($pid, $type)
 {
     $res = XDB::query('SELECT  COUNT(data)
                          FROM  requests
                         WHERE  pid = {?} and type = {?}', $pid, $type);
     return $res->fetchOneCell();
 }
예제 #29
0
파일: compare.php 프로젝트: netixx/frankiz
}
// 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']) {
                    $tables[$table][] = "* '{$field}' " . $infos['Type'] . " differs from " . $actual[$field]['Type'] . "";
                }
                if ($infos['Null'] != $actual[$field]['Null']) {
                    $tables[$table][] = "* '{$field}' " . $infos['Type'] . " differs for NULL";
                }
                if ($infos['Key'] != $actual[$field]['Key']) {
                    $tables[$table][] = "* '{$field}' " . $infos['Type'] . " differs for KEY";
                }
                if ($infos['Default'] != $actual[$field]['Default']) {
                    $tables[$table][] = "* '{$field}' " . $infos['Type'] . " differs for Default";
예제 #30
0
파일: admin.php 프로젝트: netixx/frankiz
 function handler_logs_events($page, $session)
 {
     $res = XDB::query('SELECT  la.text AS action, le.stamps, le.data
                          FROM  log_events AS le
                     LEFT JOIN  log_actions AS la ON la.id = le.action
                         WHERE  le.session = {?}
                      ORDER BY  le.stamps DESC
                         LIMIT  50', $session);
     $page->assign('title', "Logs des événements de la session");
     $page->assign('events', $res->fetchAllAssoc());
     $page->changeTpl('admin/logs_events.tpl');
 }