public function edit($nNavigationMenuId, $aData) { $oModelNavigationResource = new Admin_Model_NavigationResource(); $oModelNavigationOption = new Admin_Model_NavigationOption(); $oGenereteSessionId = new AppCms2_GenereteSessionId(); try { $this->_db->beginTransaction(); $oRow = $this->find($nNavigationMenuId)->current(); if ($oRow instanceof Zend_Db_Table_Row_Abstract) { $oRow->label = $aData["label"]; $oRow->desc = $aData["desc"]; $oRow->image_id = $aData["image_id"]; $oRow->visible = $aData["visible"]; if ($oRow->save()) { $aGenereteSessionId = $oGenereteSessionId->generatePassword(); $sNavigationResource = "menu_resource_{$aData["navigation_module_id"]}_{$aData["navigation_controller_id"]}_{$aData["navigation_action_id"]}_{$aGenereteSessionId["user_password"]}"; $nNavigationResourceId = $oModelNavigationResource->add($sNavigationResource); if (isset($nNavigationResourceId)) { $aData["navigation_resource_id"] = $nNavigationResourceId; $nNavigationOptionId = $oRow->navigation_option_id; if ($oModelNavigationOption->edit($nNavigationOptionId, $aData)) { $this->_db->commit(); return $nNavigationOptionId; } } } } $this->_db->rollBack(); return null; } catch (Zend_Exception $e) { $this->_db->rollBack(); return null; } }
public function newUser($aParam) { if (is_array($aParam) && count($aParam)) { $oModelUserParm = new Admin_Model_UserParam(); $oModelUserNewAccount = new Admin_Model_UserNewAccount(); $oGenerateSessionId = new AppCms2_GenereteSessionId(); $oBootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap"); $sOptions = $oBootstrap->getOptions(); try { $this->_db->beginTransaction(); $nTime = time(); $sSalt = md5(sha1($nTime . $sOptions["resources"]["frontController"]["salt"] . $nTime)); $oRow = $this->createRow(); if ($oRow instanceof Zend_Db_Table_Row_Abstract) { if (!isset($aParam["role_id"])) { $oRow->user_role_id = 1; } else { $oRow->user_role_id = $aParam["role_id"]; } $oRow->email_address = $aParam["email_address"]; $oRow->password = md5(md5($aParam["password"]) . $sSalt); $oRow->salt = $sSalt; $oRow->created_date = $nTime; $oRow->is_active = $aParam["is_active"]; $nUserId = $oRow->save(); if ($oModelUserParm->newUserParam($nUserId, $aParam)) { $sConfirmCode = $oGenerateSessionId->generate(); if ($oModelUserNewAccount->addConfirmCode($nUserId, $sConfirmCode)) { $this->_db->commit(); return $sConfirmCode; } } } } catch (Zend_Exception $e) { $this->_db->rollBack(); return null; } } return null; }
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null) { $oGenereteSessionId = new AppCms2_GenereteSessionId(); $file = new stdClass(); $file->name = $this->get_file_name($name, $type, $index, $content_range); $file->size = $this->fix_integer_overflow(intval($size)); $file->type = $type; if ($this->validate($uploaded_file, $file, $error, $index)) { $this->handle_form_data($file, $index); $upload_dir = $this->get_upload_path(); if (!is_dir($upload_dir)) { mkdir($upload_dir, $this->options['mkdir_mode'], true); } $file_path = $this->get_upload_path($file->name); $append_file = $content_range && is_file($file_path) && $file->size > $this->get_file_size($file_path); if ($uploaded_file && is_uploaded_file($uploaded_file)) { // multipart/formdata uploads (POST method uploads) if ($append_file) { file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); } else { move_uploaded_file($uploaded_file, $file_path); } } else { // Non-multipart uploads (PUT method support) file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); } $file_size = $this->get_file_size($file_path, $append_file); if ($file_size === $file->size) { if ($this->options['orient_image']) { $this->orient_image($file_path); } $file->url = $this->get_download_url($file->name); foreach ($this->options['image_versions'] as $version => $options) { if ($this->create_scaled_image($file->name, $version, $options)) { if (!empty($version)) { $file->{$version . '_url'} = $this->get_download_url($file->name, $version); } else { $file_size = $this->get_file_size($file_path, true); } } } } else { if (!$content_range && $this->options['discard_aborted_uploads']) { unlink($file_path); $file->error = 'abort'; } } $file->size = $file_size; $file->extension = $this->check_extension($type); $file->gen_name = $oGenereteSessionId->generateImageName() . "." . $file->extension; $file->upload_url = $this->options["upload_url"]; $this->set_file_delete_properties($file); } return $file; }
public function ordernumberAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper("layout")->disableLayout(); $oMail = new AppCms2_Controller_Plugin_Mail(); if ($this->_request->isPost()) { $aPostData = $this->_request->getPost(); $sHash = md5($aPostData["merchant_id"] . $aPostData["amount"] . $aPostData["descr"] . $aPostData["order_id"] . $aPostData["product_id"] . $aPostData["user_id"] . $aPostData["url"] . $aPostData["restricted"] . $aPostData["time"] . $this->_sAuthKey2); if ($sHash === $aPostData["hash"]) { $oModelVOrderJournal = new Borrower_Model_VOrderJournal(); $oModelOrderCart = new Borrower_Model_OrderCart(); $oModelOrderJournalOrderCart = new Borrower_Model_OrderJournalOrderCart(); $oModelOrderPayment = new User_Model_OrderPayment(); $oModelOrderPaymentHistory = new User_Model_OrderPaymentHistory(); $oModelOrderJournal = new User_Model_OrderJournal(); $oGenereteSessionId = new AppCms2_GenereteSessionId(); $oModelUser = new Admin_Model_User(); $oDb = Zend_Db_Table::getDefaultAdapter(); try { $oDb->beginTransaction(); $nUserId = (int) $aPostData["user_id"]; $nAmount = (int) $aPostData["amount"]; $oUserOrderJournal = $oModelVOrderJournal->getUserOrderJournal($nUserId); $nOrderCartId = $oModelOrderCart->getOrderCartId($nUserId); //pobiera id koszyka użytkownika foreach ($oUserOrderJournal as $oValue) { //sprawdza czy na pewno wszystkie zamówienia znajdują się w koszyku $bIsExists = $oModelOrderJournalOrderCart->findOrderJournal($oValue->id, $nOrderCartId); if (!$bIsExists) { $oModelOrderJournalOrderCart->addOrderJournalOrderCart(array("order_journal_id" => $oValue->id, "order_cart_id" => $nOrderCartId)); } } $oCart = $oModelOrderJournalOrderCart->getCartJournals($nOrderCartId); //pobiera id czasopism znajdujących się w koszyku $nCartCount = $oCart->count(); foreach ($oCart as $oValue) { $sPaymentDescr .= $oValue->order_journal_id; if ($nCartCount > 1) { $sPaymentDescr .= "; "; } } $sPaymentDescr = trim($sPaymentDescr); $aUserParam = $oModelUser->findUser($nUserId); $aPaymentParam = $oGenereteSessionId->generatePaymentParam(); $aPaymentParam["user_id"] = $nUserId; $aPaymentParam["amount"] = $nAmount; $aPaymentParam["descr"] = "Zamówienie nr " . $sPaymentDescr; $aPaymentParam["first_name"] = $aUserParam["first_name"]; $aPaymentParam["last_name"] = $aUserParam["last_name"]; $aPaymentParam["email_address"] = $aUserParam["email_address"]; $aPaymentParam["is_starting"] = 1; $aPaymentParam["date_is_starting"] = time(); $aPaymentParam["payment_type"] = 2; $nOrderPaymentId = $oModelOrderPayment->addRow($aPaymentParam); //tworzy nowy rekord w tabeli płatności i zwraca jego id $oModelOrderJournal->setOrderPaymentId($oCart, $nOrderPaymentId); //łączy czasopismo z płatnością $oModelOrderPaymentHistory->setOrderPaymentHistory($oCart, $nOrderPaymentId); //dodaje informacje do tabeli z historią płatności echo $nOrderPaymentId; $oDb->commit(); } catch (Zend_Exception $e) { $oDb->rollBack(); } } } exit; }
public function passwordremindAction() { $this->_helper->layout()->setLayout("borrower/layout_login"); $oModelUser = new Admin_Model_User(); $oModelVUser = new Admin_Model_VUser(); $oModelUserNewPassword = new Admin_Model_UserNewPassword(); $oFormPasswordRemind = new Admin_Form_PasswordRemind(); $oGenereteSessionId = new AppCms2_GenereteSessionId(); $aPostData = array(); $sSuccess = ""; if ($this->_request->isPost()) { $aPostData = $this->_request->getPost(); if ($oFormPasswordRemind->isValid($aPostData)) { $sEmailAddress = $oFormPasswordRemind->getValue("user_email_address"); $nUserId = $oModelUser->findUserByEmailAddress($sEmailAddress); if (is_numeric($nUserId)) { $aParam = $oModelVUser->getUserParam($nUserId)->toArray(); $aParam["salt"] = $oModelUser->getUserSalt($nUserId); $aParam = array_merge($aParam, $oGenereteSessionId->generatePassword($aParam["salt"])); if ($oModelUserNewPassword->addPassword($nUserId, $aParam)) { $sEmailAddress = $oModelUser->findEmailAddress($nUserId); $oMail = new AppCms2_Controller_Plugin_Mail(); $oMail->sendNewPassword($sEmailAddress, $aParam); $sSuccess = "OK"; } else { $sSuccess = "NO OK"; } } else { $sSuccess = "USER"; } } } $this->view->oFormPasswordRemind = $oFormPasswordRemind; $this->view->sSuccess = $sSuccess; }