/**
  * Returns a new LicenseQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   LicenseQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return LicenseQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof LicenseQuery) {
         return $criteria;
     }
     $query = new LicenseQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Пример #2
0
 /**
  * Display form for license activation
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function aboutAction()
 {
     $oLicense = LicenseQuery::create()->findOne();
     // include symfony requirements class
     require_once dirname(__FILE__) . '/../../../../app/SymfonyRequirements.php';
     $symfonyRequirements = new \SymfonyRequirements();
     // add additional requirement for mcrypt
     $symfonyRequirements->addRequirement(extension_loaded('mcrypt'), "Check if mcrypt ist loaded for RSA encryption", "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>");
     // fetch all data
     $aRequirements = $symfonyRequirements->getRequirements();
     $aRecommendations = $symfonyRequirements->getRecommendations();
     $aFailedRequirements = $symfonyRequirements->getFailedRequirements();
     $aFailedRecommendations = $symfonyRequirements->getFailedRecommendations();
     $iniPath = $symfonyRequirements->getPhpIniConfigPath();
     $sVersion = file_get_contents(dirname(__FILE__) . '/../../../../version.txt');
     return $this->render('SlashworksAppBundle:About:about.html.twig', array("license" => $oLicense, "version" => $sVersion, "iniPath" => $iniPath, "requirements" => $aRequirements, "recommendations" => $aRecommendations, "failedrequirements" => $aFailedRequirements, "failedrecommendations" => $aFailedRecommendations));
 }
Пример #3
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(LicensePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = LicenseQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * Update license
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  * @throws \Exception
  * @throws \PropelException
  */
 public function updateAction(Request $request)
 {
     /** @var License $oLicense */
     $oLicense = LicenseQuery::create()->findOne();
     if ($oLicense === null) {
         throw $this->createNotFoundException('Unable to find License entity.');
     }
     $editForm = $this->createEditForm($oLicense);
     $editForm->handleRequest($request);
     $aResult = array("success" => false, "message" => "");
     $sLico = SystemSettings::get("lico");
     $aHeaders = array('Content-Type: application/json');
     $sDomain = $this->_getSiteURL();
     $aRequest = array('lico' => array('domain' => $sDomain, 'license' => $oLicense->getSerial()));
     $sRequest = json_encode($aRequest);
     /*
      * Check license against license-server
      */
     $oRequest = curl_init($sLico . "/api/check/license");
     curl_setopt($oRequest, CURLOPT_HTTPHEADER, $aHeaders);
     curl_setopt($oRequest, CURLOPT_TIMEOUT, 120);
     curl_setopt($oRequest, CURLOPT_POST, 1);
     curl_setopt($oRequest, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($oRequest, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest);
     curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true);
     $response = curl_exec($oRequest);
     $iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE);
     $error = curl_error($oRequest);
     curl_close($oRequest);
     if ($iHttpStatus == 200) {
         $oResponse = json_decode($response);
         if ($editForm->isValid() && $oResponse->valid == true) {
             $aResult['max_clients'] = $oResponse->max_clients;
             $aResult['valid_until'] = $oResponse->valid_until;
             $aResult['domain'] = $sDomain;
             $aResult['success'] = true;
             $aResult['message'] = $this->get("translator")->trans("license.update.successful");
             // license valid, save new license-data
             $oLicense->setValidUntil($aResult['valid_until']);
             $oLicense->setMaxClients($aResult['max_clients']);
             $oLicense->setDomain($sDomain);
             $oLicense->save();
         } else {
             $aResult['success'] = false;
             $aResult['message'] = $this->get("translator")->trans("license.update.failed");
             $aResult['valid_until'] = strtotime("1970-01-01");
             $aResult['max_clients'] = 0;
             $aResult['domain'] = "-";
         }
     } else {
         $aResult['max_clients'] = $oLicense->getMaxClients();
         $aResult['valid_until'] = strtotime($oLicense->getValidUntil());
         $aResult['domain'] = $sDomain;
         $aResult['success'] = false;
         $aResult['message'] = $this->get("translator")->trans("license.update.failed_lico");
     }
     $sResult = json_encode($aResult);
     $response = new Response($sResult);
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }