public function executeProcessSale() { $this->setLayout(false); $this->result = false; $request = $this->getRequest(); $request->setParameter('x_exp_date', $this->getRequestParameter("exp_month") . "/" . $this->getRequestParameter("exp_year")); $request->setParameter("exp_month", ""); $request->setParameter("exp_year", ""); if ($this->getRequestParameter("submitted")) { if (array_key_exists("cart", $_SESSION)) { $products = array(); foreach ($_SESSION["cart"] as $item) { $doc = Document::getDocumentInstance($item); if ($doc) { $cnt = $_SESSION["num"][$item]; if (!$cnt) { $cnt = 1; } $price = $doc->getPrice(); $price = $price * $cnt; echo "price:" . $price . "<br>"; $totalPrice += $price; } } $totalPrice += round($totalPrice * (UtilsHelper::Settings("taxes") / 100), 2); } require_once sfConfig::get('sf_web_dir') . '/anet_php_sdk/AuthorizeNet.php'; $transaction = new AuthorizeNetAIM(); $transaction->setSandbox(AUTHORIZENET_SANDBOX); $transaction->setFields(array('amount' => $totalPrice, 'card_num' => $this->getRequestParameter('x_card_num'), 'exp_date' => $this->getRequestParameter('x_exp_date'), 'first_name' => $this->getRequestParameter('x_first_name'), 'last_name' => $this->getRequestParameter('x_last_name'), 'address' => $this->getRequestParameter('x_address'), 'email' => $this->getRequestParameter('x_email'), 'city' => $this->getRequestParameter('x_city'), 'state' => $this->getRequestParameter('x_state'), 'country' => $this->getRequestParameter('x_country'), 'zip' => $this->getRequestParameter('x_zip'), 'email' => $this->getRequestParameter('x_email'), 'card_code' => $this->getRequestParameter('x_card_code'))); $transaction->setCustomFields(array('products' => $this->getRequestParameter('x_delivery_address'))); $response = $transaction->authorizeAndCapture(); $this->response = $response; if (!$this->getRequestParameter('terms')) { $request->setError('errterms', "Please accept the terms of use"); UtilsHelper::setFlashMsg('', UtilsHelper::MSG_ERROR); } else { if ($response->approved) { $this->result = "success"; $this->transaction_id = $response->transaction_id; $message = "\n\t\t\t\t\tYou successfully ordered products from SubcommPools.com<br>\n\t\t\t\t\t<br>Date:" . date('l jS \\of F Y h:i:s A') . "<br>\n\t\t\t\t\t<br>Transaction number:" . $response->transaction_id . "<br>\n\t\t\t\t\t<br>Name: " . $this->getRequestParameter('x_first_name') . " " . $this->getRequestParameter('x_last_name') . "<br>\n\t\t\t\t\t<br>-------------------<br><br>"; foreach ($_SESSION["cart"] as $item) { $doc = Document::getDocumentInstance($item); if ($doc) { $itemCnt = $_SESSION["num"][$item]; if (!$itemCnt) { $itemCnt = 1; } $itemPrice = $doc->getPrice(); $itemPrice = $itemPrice * $cnt; $message .= $doc->getLabel() . ", Quantity: " . $itemCnt . ", \$" . $itemPrice . "<br>"; } } $message .= "<br>Total+Tax: \$" . $totalPrice . "<br>\n\t\t\t\t\t<br>Thank you for your purchase."; UtilsHelper::sendEmail($this->getRequestParameter('x_email'), $message, "SubcommPools Purchase", UtilsHelper::Settings("main_email"), "SubcommPools", UtilsHelper::Settings("main_email")); $_SESSION["cart"] = null; $_SESSION["num"] = null; } else { $this->response_text = $response->response_reason_text; //var_dump($response); $request->setError('errsubmit', $response->response_reason_text); UtilsHelper::setFlashMsg('', UtilsHelper::MSG_ERROR); //$this->result = $response->response_reason_text; //header('Location: error_page.php?response_reason_code='.$response->response_reason_code.'&response_code='.$response->response_code.'&response_reason_text=' .$response->response_reason_text); } } } }
public function validateResetPassword() { $result = false; if ($login = $this->getRequestParameter('resetpassword')) { $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $user = UserPeer::doSelectOne($c); if ($user) { $now = time(); // Set user activation code $user->setActivationCode($now); $user->save(); $changePassPage = Document::getDocumentByExclusiveTag("website_page_changepassword"); if ($changePassPage) { $reset_link = "<a href='" . $changePassPage->getHref() . "?q={$now}'>Reset password</a>"; } $text = "Hi " . $user->getLabel() . "!\n\t\t\t\t<br/>\n\t\t\t\t<br/>Please click this link to reset your password:\n\t\t\t\t<br/>{$reset_link}\n\t\t\t\t"; //$this->getPresentationFor('user', 'resetPasswordMessage'); UtilsHelper::sendEmail($user->getEmail(), $text, "Password reset"); $result = true; } else { UtilsHelper::setFlashMsg('Wrong login email.', UtilsHelper::MSG_ERROR); } } return $result; }
function run_session_search($task, $args) { ini_set("memory_limit", "8192M"); ini_set("display_errors", 1); define('SF_ROOT_DIR', sfConfig::get('sf_root_dir')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', true); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); //sfConfig::set('sf_cache_objects', false); //sfConfig::set('sf_cache_relations', false); //sfConfig::set('sf_use_relations_cache', false); //get all serch templates $c = new Criteria(); $searcheTemplates = SearchPeer::doSelect($c); //$searcheTemplates = array($st); $fields = array('Label', 'ApplicationNumber', 'RegisterNumber', 'RegistrationDate', 'ApplicationDate', 'ExpiresOn', 'ViennaClasses', 'NiceClasses', 'RightsOwner', 'RightsRepresentative', 'OfficeOfOrigin', 'DesignatedContractingParty'); $c = new Criteria(); //$c->add(ImportSessionPeer::CREATED_AT, "2014-11-03", Criteria::GREATER_EQUAL ); $importSessions = ImportSessionPeer::doSelect($c); /*if($args[0] == "-d") { foreach ($importSessions as $importSession) { $res = Document::getChildrenOf($importSession->getId(), "SearchMatch"); foreach ($res as $r) { $r->delete(); echo "."; } } exit(); }*/ $ind = 0; foreach ($importSessions as $importSession) { $found = false; if ($importSession->getTmCount() == 0) { continue; } $searchMatches = Document::getChildrenOf($importSession->getId(), "SearchMatch", false); //if($importSession->getId() == 552172) continue; if (count($searchMatches) > 0) { continue; } echo ">>> searching session: " . $importSession->getId() . "\n"; try { $sti = 1; foreach ($searcheTemplates as $searcheTemplate) { $searchOf = array(); foreach ($fields as $field) { $getter = "get" . $field; $param = $searcheTemplate->{$getter}(); if ($param) { $param = str_replace(array('+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', ':', '\\', '.', '/'), array('\\+', '\\-', '\\&&', '\\||', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\"', '\\~', '\\:', '\\\\', '\\.', '\\/'), $param); $searchOf[$field] = trim($param); } } /////////////////////// QUERY BUILDING ////////////////////////// $q = new Zend_Search_Lucene_Search_Query_Boolean(); $queryTerms = explode(" ", strtolower($query)); $i = 0; $query = ""; foreach ($searchOf as $field => $term) { if ($i > 0) { $query .= ' AND '; } if ($field == "NiceClasses" || $field == "ViennaClasses") { $query .= '('; $parts = explode(",", $term); foreach ($parts as $el) { for ($e = 1; $e < 15; $e++) { $query .= $field . $e . ':"' . trim($el) . '" OR '; } } $query = substr($query, 0, -4) . ')'; } elseif ($field == "ApplicationNumber" || $field == "RegisterNumber") { $query .= $field . ':'; $query .= trim($term); } else { $query .= $field . ':'; if (strpos($term, "*") !== false || strpos($term, "?") !== false) { $query .= trim(UtilsHelper::cyrillicConvert($term)); } else { $query .= trim(UtilsHelper::cyrillicConvert($term)) . '~0.7'; } } $i++; } $q = Zend_Search_Lucene_Search_QueryParser::parse($query); //////////////////////// SEARCH EXECUTION //////////////////// echo " | " . $sti . " > " . $searcheTemplate->getId(); $searchIndex = Zend_Search_Lucene::open(sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'search/' . $importSession->getId() . "/"); $searchResults = $searchIndex->find($q); $brandId = Document::getParentOf($searcheTemplate->getId(), "Brand", false); foreach ($searchResults as $searchResult) { if ($foundEls[$searchResult->did] == $brandId) { continue; } $foundEls[$searchResult->did] = $brandId; $found = true; $sm = new SearchMatch(); $sm->setLabel("Match"); $sm->setImportSession($importSession->getId()); $sm->setSearch($searcheTemplate->getId()); $sm->setTrademark($searchResult->did); $sm->save(null, $importSession); } $sti++; } if ($found) { UtilsHelper::sendEmail(UtilsHelper::Settings('main_email'), "Matches have been found, click below to see them <br> <a href='http://www.tm-smart.com/import-session-report.html?is=" . $importSession->getId() . "'>http://www.tm-smart.com/import-session-report.html?is=" . $importSession->getId() . "</a>", "TM Smart - Matches foud"); $ind++; } else { // UtilsHelper::sendEmail(UtilsHelper::Settings('main_email'), "No matches have been found", "TM Smart - No matches foud"); } } catch (Exception $e) { echo ">>>>>>>>>> Error on Session " . $importSession->getId() . "\n" . $e->getMessage(); continue; //echo_cms_error("ERROR: ".$e->getMessage()); } if ($ind > 10) { break; } } //sfConfig::set('sf_cache_objects', true); //sfConfig::set('sf_cache_relations', true); //sfConfig::set('sf_use_relations_cache', true); }