Beispiel #1
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $contact_req = new ContactRequest();
         $contact_req->setRequestDate(date('Y-m-d'));
         $contact_req->setTitle($request->getParameter('contact_request[title]'));
         $contact_req->setFirstName($request->getParameter('contact_request[first_name]'));
         $contact_req->setLastName($request->getParameter('contact_request[last_name]'));
         $contact_req->setAddress1($request->getParameter('contact_request[address1]'));
         $contact_req->setAddress2($request->getParameter('contact_request[address2]'));
         $contact_req->setCity($request->getParameter('contact_request[city]'));
         $contact_req->setState($request->getParameter('contact_request[state]'));
         $contact_req->setZipcode($request->getParameter('contact_request[zipcode]'));
         $contact_req->setCountry($request->getParameter('contact_request[country]'));
         $contact_req->setDayPhone($request->getParameter('contact_request[day_phone]'));
         $contact_req->setEvePhone($request->getParameter('contact_request[eve_phone]'));
         $contact_req->setFaxPhone($request->getParameter('contact_request[fax_phone]'));
         $contact_req->setMobilePhone($request->getParameter('contact_request[mobile_phone]'));
         $contact_req->setEmail($request->getParameter('contact_request[email]'));
         $contact_req->setRefSourceId($request->getParameter('contact_request[ref_source_id]'));
         $contact_req->setSendAppFormat($request->getParameter('contact_request[send_app_format]'));
         $contact_req->setComment($request->getParameter('contact_request[comment]'));
         //Set Session Id
         $sessionId = session_id();
         $contact_req->setSessionId($sessionId);
         //end set session id
         $contact_req->setIpAddress($request->getRemoteAddress());
         $contact_req->save();
         $this->redirect('contact_request/thankyou');
     }
 }
Beispiel #2
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new IngresoInventarioForm();
     if ($request->isMethod('POST')) {
         $this->form->bind($request->getParameter('ingreso_inventario'));
         if ($this->form->isValid()) {
             $valores = $this->form->getValues();
             $BitacoraCambios = new BitacoraCambios();
             $BitacoraCambios->setModelo('Inventario');
             $Producto = ProductoQuery::create()->findOneById($valores['Producto']);
             $BitacoraCambios->setDescripcion('Ingreso de Inventario de Producto: ' . $Producto->getDescripcion() . ' con cantidad ' . $valores['Cantidad']);
             $BitacoraCambios->setIp($request->getRemoteAddress());
             $Usuario = UsuarioQuery::create()->findOneById(sfContext::getInstance()->getUser()->getAttribute('usuario', null, 'seguridad'));
             if ($Usuario) {
                 $BitacoraCambios->setCreatedBy($Usuario->getUsuario());
             }
             $Movimiento = new Movimiento();
             $Movimiento->setTipoMovimiento('+');
             $Movimiento->setProveedorId($valores['Proveedor']);
             $Movimiento->setProductoId($Producto->getId());
             $Movimiento->setCantidad($valores['Cantidad']);
             $Movimiento->setPrecio($valores['Precio']);
             $Movimiento->save();
             $BitacoraCambios->save();
             $Comprobacion = InventarioQuery::create()->filterByProductoId($valores['Producto'])->filterByProveedorId($valores['Proveedor'])->findOne();
             if ($Comprobacion) {
                 $Comprobacion->setCantidad($Comprobacion->getCantidad() + $valores['Cantidad']);
                 $anterior = $Comprobacion->getCantidad() * $Comprobacion->getPrecioCompra();
                 $actual = $valores['Cantidad'] * $valores['Precio'];
                 $suma = ($anterior + $actual) / ($valores['Cantidad'] + $Comprobacion->getCantidad());
                 $Comprobacion->setPrecioCompra($suma);
                 $Comprobacion->save();
             } else {
                 $Inventario = new Inventario();
                 $Inventario->setPrecioCompra($valores['Precio']);
                 $Inventario->setProductoId($valores['Producto']);
                 $Inventario->setProveedorId($valores['Proveedor']);
                 $Inventario->setCantidad($valores['Cantidad']);
                 $Inventario->save();
             }
             $this->redirect('inventario/index');
         }
     }
     $this->cinco = InventarioQuery::create()->orderById('DESC')->limit(5)->find();
 }
Beispiel #3
0
 public function executeIndex(sfWebRequest $request) {
     // vehicles
     $q = Doctrine_Query::create()
       ->from('ShowmobileVehicle v')
       ->where('v.user_id = ?',$this->getUser()->getProfile()->getID());
     
     $this->vehicles = $q->execute(); 
     // drives
     $q = Doctrine_Query::create()
       ->from('ShowmobileDriver d')
       ->where('d.user_id = ?',$this->getUser()->getProfile()->getID());
     
     $this->drives = $q->execute(); 
     //passengers
     $q = Doctrine_Query::create()
       ->from('ShowmobilePassenger p')
       ->leftJoin('p.Driver d')
       ->where('d.user_id = ?',$this->getUser()->getProfile()->getID());
     
     $this->passengers = $q->execute(); 
     //rides
     $q = Doctrine_Query::create()
       ->from('ShowmobilePassenger p')
       ->where('p.user_id = ?',$this->getUser()->getProfile()->getID());
     
     $this->rides = $q->execute(); 
     //events
     $q = Doctrine_Query::create()
       ->from('ShowmobileEvent e')
       ->leftJoin('e.Venue v')
       ->leftJoin('v.Address a');
       
     
     $this->events = $q->execute();
     
     //gmap
     $this->gMap = new GMap();
     $this->getUser()->locale = new ip2location($request->getRemoteAddress());
     $this->gMap->addMarker(new GMapMarker($this->getUser()->locale->Latitude,$this->getUser()->locale->Longitude));
     $this->gMap->centerAndZoomOnMarkers();
 }
Beispiel #4
0
 /**
  * Process a vote for a douche
  * @param sfWebRequest $request
  * @param bool $direction true for is a douche, false for not a douche
  * @return <type>
  */
 protected function processVote(sfWebRequest $request, $direction)
 {
     $this->douche = $this->getRoute()->getObject();
     // Check the user's hash and the cookie's hash
     // Then make sure that the hash is valid for this specific douche
     // based upon what they were viewing
     if ($this->getUser()->getAttribute('dvote_hash') != $this->getRequest()->getCookie('dvote') || $this->getUser()->getAttribute('dvote_for') != $this->douche->getId()) {
         $this->forward404('Yikes, that did not want to go, did it?');
     }
     // Overwrite the dvote hash to prevent them from voting on the same person
     // over and over
     $this->getUser()->setAttribute('dvote_hash', null);
     if ($direction) {
         $vote_score = 1;
     } else {
         $vote_score = -1;
     }
     // Create the vote for the douche
     $vote = new DoucheVote();
     $vote->setDouche($this->douche);
     $vote->setSubmitIp($request->getRemoteAddress());
     $vote->setVote($vote_score);
     $vote->save();
     $this->direction = (bool) $direction;
     $this->name = $this->douche->getTwitterName();
     $this->upvotes = $this->douche->getUpVotes();
     $this->downvotes = $this->douche->getDownVotes();
     $this->setTemplate('vote');
     return sfView::SUCCESS;
 }
 public function executeNew(sfWebRequest $request)
 {
     $douche = new Douche();
     $douche->setSubmitIp($request->getRemoteAddress());
     $this->form = new NewDoucheForm($douche);
 }
 protected function copyDepositInfoToPaymentData(sfWebRequest $request, $payment)
 {
     $data = $payment->getDataContainer();
     if (!$data instanceof _4bPaymentData) {
         throw new LogicException('The payment has a type of data container not suitable for 4b payments.');
     }
     $data->store = $request->getParameter('store');
     $data->order_ref = $request->getParameter('pszPurchorderNum');
     $data->transaction_result = $request->getParameter('result');
     $data->transaction_type = $request->getParameter('tipotrans');
     $data->transaction_from_ip = $request->getRemoteAddress();
     $data->transaction_date = $request->getParameter('pszTxnDate');
     $data->transaction_approval_code = $request->getParameter('pszApprovalCode');
     $data->transaction_id = $request->getParameter('pszTxnID');
     $data->transaction_error_code = $request->getParameter('coderror');
     $data->transaction_error_description = $request->getParameter('deserror');
     $data->save();
 }
Beispiel #7
0
 /**
  * Executes map action
  *
  * @param sfRequest $request A request object
  */
 public function executeLocations(sfWebRequest $request)
 {
     $this->ip = $request->getRemoteAddress();
 }
Beispiel #8
0
 /**
  * ANNOUNCE
  *
  *  info_hash=%c5Q%00%c9%cc%ff%fexC%f7%0fN%00-%1b%ad%01%3a%3a%f2&
  *  peer_id=-UT2210-%d6bM%24%7dou%1ea%ff%3b%a6&
  *  port=54298&uploaded=0&downloaded=0&left=7054990212&corrupt=0&
  *  key=924042E0&
  *  event=started&
  *  numwant=200&
  *  compact=1&
  *  no_peer_id=1&
  *  ipv6=2a01%3ae34%3aee26%3a9530%3aad45%3af4e7%3a1ce3%3a25c2
  */
 public function executeAnnounce(sfWebRequest $r)
 {
     $return = array();
     // If it's a browser, redirect to homepage
     if (preg_match('#Mozilla#', $r->getHttpHeader('User-Agent'))) {
         $this->redirect("@homepage");
     }
     // Injecting correct MIME for BT clients
     $this->getResponse()->setContentType("text/plain");
     // ** STAGE 1 : ACCOUNT
     // Building the query with cache
     $mbr = Doctrine_Query::create()->select("u.role, u.pid")->from('Users u')->leftJoin('u.Ips i')->useQueryCache(true)->setQueryCacheLifeSpan(3600 * 24)->useResultCache(true)->setResultCacheLifeSpan(900);
     // Is BT client is sending a PID
     if ($r->hasParameter("pid")) {
         $mbr->addWhere('u.pid = ?', $r->getParameter("pid"));
     } else {
         $mbr->addWhere('i.ip = ?', $r->getRemoteAddress());
     }
     // Execute request
     $m = $mbr->execute();
     // If system can't find the right account
     if (count($m) !== 1) {
         $this->btSendError("Sorry, I'm unable to authenticate you. Please, check PID or IP.");
     }
     $mbr = $m[0];
     // Can we access to this torrent ?
     if (in_array($mbr->getRole(), array("ban", "val"))) {
         $this->btSendError("You don't have the sufficient rights.");
     }
     // ** STAGE 2 : HASH
     if (!$r->hasParameter("info_hash")) {
         $this->btSendError("I need an info_hash.");
     }
     // Hashing the hash... yeah i'm not very inspired for this comment ^^
     // Symfony is corrupting my hash, getting the right one from $_SERVER. Not very clean, but it works.
     preg_match('#info_hash=(.*)&#U', $_SERVER['QUERY_STRING'], $hash);
     $hash = bin2hex(urldecode($hash[1]));
     if (!preg_match('#([0-9a-f]{40})#', $hash)) {
         $this->btSendError("Invalid hash.");
     }
     // Getting the torrent and related peers & co
     $torrent = Doctrine_Query::create()->select('t.minlevel, p.*, o.*')->from("Uploads t")->leftJoin('t.TorrentsPeers p WITH p.updated_at > ?', date('Y-m-d H:i:s', time() - 3600))->leftJoin('t.TorrentsPeersOffset o WITH o.pid = ?', $mbr->getPid())->where('t.hash = ?', $hash)->useQueryCache(true)->setQueryCacheLifeSpan(3600 * 24)->execute(array(), Doctrine::HYDRATE_ARRAY);
     // If hash not found
     if (count($torrent) !== 1) {
         $this->btSendError("Torrent not found.");
     }
     $this->torrent = $torrent[0];
     // If we don't have the required level
     if ($mbr->getLevel() < $this->torrent['minlevel']) {
         $this->btSendError("You don't have the required level");
     }
     // Is client asking for a compact response ?
     $this->isCompact = $r->getParameter("compact") == "1" ? true : false;
     // Can I provide PeerId to client ?
     $this->noPeerId = $r->getParameter("no_peer_id") == "1" || $this->isCompact ? true : false;
     // Is client giving the right port number ?
     $port = $r->getParameter("port");
     if (!is_numeric($port) && $port > 0 && $port < 65535) {
         $this->btSendError("Invalid port number.");
     }
     // Number of peers asked by client (50 by default)
     $numPeers = $r->getParameter("numwant") > 0 ? (int) $r->getParameter("numwant") : 50;
     // Peer_id of current client
     $peer_id = bin2hex(urldecode($r->getParameter("peer_id")));
     if (!preg_match('#([0-9a-f]{40})#', $peer_id)) {
         $this->btSendError("Invalid PeerID.");
     }
     // Processing offset
     if (count($this->torrent['TorrentsPeersOffset']) === 1) {
         $download = $this->torrent['TorrentsPeersOffset'][0]['download'] + $r->getParameter("downloaded");
         $upload = $this->torrent['TorrentsPeersOffset'][0]['upload'] + $r->getParameter("uploaded");
     } else {
         $download = (int) $r->getParameter("downloaded");
         $upload = (int) $r->getParameter("uploaded");
     }
     // If freeleech, don't care about download
     if ($this->torrent['minlevel'] == 0) {
         $download = 0;
     }
     // Processing events
     switch ($r->getParameter("event")) {
         // Regular update, just sending current peers
         case "":
             $return['peers'] = $this->btGetPeers($numPeers);
             break;
             // Client is starting transfer
         // Client is starting transfer
         case "started":
             // Updating offset
             $o = new TorrentsPeersOffset();
             $o->setHash($hash);
             $o->setPid($mbr->getPid());
             $o->setDownload($download);
             $o->setUpload($upload);
             $o->replace();
             // Send peerlist
             $return['peers'] = $this->btGetPeers($numPeers);
             break;
             // Client is stopping
         // Client is stopping
         case "stopped":
             // Saving offset
             $o = new TorrentsPeersOffset();
             $o->setHash($hash);
             $o->setPid($mbr->getPid());
             $o->setDownload($download);
             $o->setUpload($upload);
             $o->replace();
             break;
             // Completed
         // Completed
         case "completed":
             // Sending new peerlist to client
             $return['peers'] = $this->btGetPeers($numPeers);
             break;
             // If client is sending an unexcepted event
         // If client is sending an unexcepted event
         default:
             $this->btSendError("Invalid event.");
     }
     // Complete the return response
     $return['interval'] = sfConfig::get("app_bt_interval", 900);
     // Time between updates
     $return['min interval'] = sfConfig::get("app_bt_interval", 900);
     // Keep theses values over 60sec
     // Include stats
     $stats = $this->btGetPeers($numPeers, true);
     $return['complete'] = $stats[0];
     $return['incomplete'] = $stats[1];
     // Sending array to client
     require_once "../lib/bittorrent/Autoload.php";
     $encoder = new PHP_BitTorrent_Encoder();
     echo $encoder->encode($return);
     // Are we in the peerlist ? Doing a quick scan
     $inPeerList = false;
     foreach ($this->torrent['TorrentsPeers'] as $p) {
         if ($p['uid'] == $mbr->getId()) {
             $inPeerList = true;
         }
     }
     // If we are, just updating some datas
     if ($inPeerList) {
         Doctrine_Query::create()->update("TorrentsPeers")->set('updated_at', 'NOW()')->set('ip', '"' . $r->getRemoteAddress() . '"')->set('port', $port)->set('download', $download)->set('upload', $upload)->set('remain', $r->getParameter("left"))->where("hash = ?", $hash)->andWhere("pid = ?", $mbr->getPid())->execute();
     } else {
         $q = new TorrentsPeers();
         $q->setHash($hash);
         $q->setPid($mbr->getPid());
         $q->setPeerId($peer_id);
         $q->setUid($mbr->getId());
         $q->setIp($r->getRemoteAddress());
         $q->setPort($port);
         $q->setDownload($download);
         $q->setUpload($upload);
         $q->setRemain($r->getParameter("left"));
         $q->setUseragent($r->getHttpHeader('User-Agent'));
         $q->replace();
     }
     return sfView::NONE;
 }
Beispiel #9
0
 public function executeEdita(sfWebRequest $request)
 {
     $this->id = $request->getParameter('id');
     $iddet = $request->getParameter('det');
     $dets = DetallePedidoProveedorQuery::create()->filterById($iddet)->findOne();
     $this->form = new IngresoDetallePedidoProveedorForm(array("Producto" => $dets->getProducto(), "Cantidad" => $dets->getCantidad(), "Precio" => $dets->getPrecio()));
     if ($request->isMethod('POST')) {
         $this->form->bind($request->getParameter('ingreso_detpedprov'));
         if ($this->form->isValid()) {
             $valores = $this->form->getValues();
             $BitacoraCambios = new BitacoraCambios();
             $BitacoraCambios->setModelo('Detalle Pedido Proveedores');
             $BitacoraCambios->setDescripcion('Edicion de Detalle de  Pedido a Proveedor con id :' . $iddet);
             $BitacoraCambios->setIp($request->getRemoteAddress());
             $pedido = $dets;
             $Usuario = UsuarioQuery::create()->findOneById(sfContext::getInstance()->getUser()->getAttribute('usuario', null, 'seguridad'));
             $pedido->setProductoId($valores['Producto']);
             $pedido->setCantidad($valores['Cantidad']);
             $pedido->setPrecio($valores['Precio']);
             $pedido->save();
             $url = 'pedido_proveedor/detalle?id=' . $this->id;
             $this->redirect($url);
         }
     }
 }
Beispiel #10
0
 /**
  * Menu des options
  */
 public function executeOptions(sfWebRequest $r)
 {
     $a = array();
     // Loading forms with our session
     $avt = new AvatarForm($this->getUser()->getAttribute("ses"));
     $usr = new UsersForm($this->getUser()->getAttribute("ses"));
     $invites = new InvitesForm();
     $ipForm = new IpsForm();
     $ipForm->setDefault('ip', $r->getRemoteAddress());
     // Tab for avatar changing
     $a['avatar'] = $this->getTab("Avatar", "picture_edit.png", $this->getPartial($this->getModuleName() . "/avatar", array("form" => $avt)));
     // Loading IPs
     $ips = Doctrine::getTable("Ips")->findByUid($this->getUser()->getAttribute("id"));
     $a['ips'] = $this->getTab("IP address", "ip.png", $this->getPartial($this->getModuleName() . "/ip", array("form" => $ipForm, "ips" => $ips)));
     // Loading invitation codes if enabled
     if (sfConfig::get("app_invitation")) {
         // Getting codes
         $codes = Doctrine::getTable("Invites")->findByUid($this->getUser()->getAttribute("id"));
         // Building tab
         $a['invites'] = $this->getTab("Invitations", "cup.png", $this->getPartial($this->getModuleName() . "/invites", array("form" => $invites, "codes" => $codes)));
     }
     $a["options"] = $this->getTab("Options", "gear_in.png", $this->getPartial($this->getModuleName() . "/edit_profile", array("f" => $usr)));
     // If we've posted someting
     if ($r->isMethod('post')) {
         // If we've uploaded a new avatar
         if ($r->hasParameter("avatars")) {
             // Binding fields
             $avt->bind($r->getParameter($avt->getName()), $r->getFiles($avt->getName()));
             // If everything is OK
             if ($avt->isValid()) {
                 // Record in DB
                 $avt->save();
                 // Tell it to frontend
                 $this->getUser()->setFlash("notice", "Your avatar has been saved !");
                 $this->redirect('@homepage');
             }
         } elseif ($r->hasParameter("profile")) {
             // Binding fields
             $usr->bind($r->getParameter($usr->getName()));
             // If form is valid
             if ($usr->isValid()) {
                 // Save
                 $usr->save();
                 return $this->renderText("ok");
             }
         }
     } else {
         return $this->renderText(json_encode(array("right" => $a)));
     }
 }