예제 #1
0
파일: log.class.php 프로젝트: badtux/pmg
 /**
  *
  * @param Request $request
  */
 public static function logRequest($request)
 {
     $ds = Ds::connect(ds_requests);
     $loggable = $request->getLoggableRequest();
     if (!is_null($loggable)) {
         $ds->insert($loggable);
     }
 }
예제 #2
0
파일: utils.class.php 프로젝트: badtux/pmg
 public static function shortenUrlV2($batch, $url = null, $shortened = false, $save = false)
 {
     $ds = Ds::connect(ds_bands);
     $times = 0;
     if ($shortened) {
         //find the band and return
         $band = $ds->findOne(array('_id' => $shortened));
         if ($band) {
             return $band;
         } else {
             return false;
         }
     }
     if (!is_null($url)) {
         //convert the url to shrten form
         $shortened = self::getShortenForm($url);
         $insert = array('_id' => $shortened, 'ts' => time(), 'batch' => $batch, 'registered' => false);
         try {
             $ds->insert($insert, array('safe' => true));
             return $shortened;
         } catch (Exception $e) {
             switch ($e->getCode()) {
                 case 11000:
                     $times++;
                     if ($times < 500) {
                         self::shortenUrlV2($batch, $url);
                     }
                     break;
             }
         }
     }
 }
예제 #3
0
 /**
  *
  * destroy the session. trigger on session_destroy
  * @param string $id
  */
 public static function destroy($id)
 {
     $ds = Ds::connect(ds_token);
     $sessId = "sess_" . $id;
     $ds->remove(array('snid' => $id));
     self::$_db->delete($sessId . "_expire");
     return self::$_db->delete($sessId);
 }