function save()
 {
     global $objDatabase, $_ARRAYLANG;
     $arrFields = array('title' => $this->title, 'UserRestriction' => $this->surveyType, 'description' => $this->description, 'textAfterButton' => $this->textBeginSurvey, 'text1' => $this->textBeforeSubscriberInfo, 'text2' => $this->textBelowSubmit, 'thanksMSG' => $this->textFeedbackMsg, 'isHomeBox' => (int) $this->isStandred(), 'additional_salutation' => $this->salutation, 'additional_nickname' => $this->nickname, 'additional_forename' => $this->forename, 'additional_surname' => $this->surname, 'additional_agegroup' => $this->agegroup, 'additional_email' => $this->email, 'additional_phone' => $this->phone, 'additional_street' => $this->street, 'additional_zip' => $this->zip, 'additional_city' => $this->city);
     if (empty($this->id)) {
         $query = \SQL::insert('module_survey_surveygroup', $arrFields, array('escape' => true));
     } else {
         $arrFields['updated'] = date("Y-m-d H:i:s");
         $query = \SQL::update('module_survey_surveygroup', $arrFields, array('escape' => true)) . " WHERE `id` = {$this->id}";
     }
     // echo $query;
     if ($objDatabase->Execute($query)) {
         $this->okMsg[] = empty($this->id) ? $_ARRAYLANG['TXT_SURVEY_ADDED_SUC_TXT'] : $_ARRAYLANG['TXT_SURVEY_UPDATE_SUC_TXT'];
         return true;
     } else {
         $this->errorMsg[] = $_ARRAYLANG['TXT_SURVEY_ERROR_IN_SAVING'];
         return true;
     }
 }
Example #2
0
 public static function PUT($req)
 {
     $table = Common::route($req);
     $sql['table'] = $table;
     $data = Common::where($req, $table);
     if (isset($data['unknown'])) {
         print 'unknown columns: ' . implode(',', $data['unknown']);
     } else {
         if (isset($data['where'])) {
             foreach ($data['where'] as $idx => $val) {
                 if ($idx == 0) {
                     $sql['where'] = $val;
                 } else {
                     $sql['set'][] = str_replace("NULL", "", $val);
                 }
             }
             SQL::update($sql);
         } else {
             print 'invalid request';
         }
     }
 }
 /**
  * Update job
  * @global     object    $objDatabase
  * @return    boolean   result
  */
 function update()
 {
     global $objDatabase, $_ARRAYLANG;
     if (empty($_POST['id'])) {
         return true;
     }
     $objFWUser = \FWUser::getFWUserObject();
     $id = intval($_POST['id']);
     $userId = $objFWUser->objUser->getId();
     $changelog = mktime();
     $title = get_magic_quotes_gpc() ? strip_tags($_POST['jobsTitle']) : addslashes(strip_tags($_POST['jobsTitle']));
     $text = get_magic_quotes_gpc() ? $_POST['jobsText'] : addslashes($_POST['jobsText']);
     $title = str_replace("ß", "ss", $title);
     $text = $this->filterBodyTag($text);
     $text = str_replace("ß", "ss", $text);
     $workloc = get_magic_quotes_gpc() ? strip_tags($_POST['workloc']) : addslashes(strip_tags($_POST['workloc']));
     $workload = get_magic_quotes_gpc() ? strip_tags($_POST['workload']) : addslashes(strip_tags($_POST['workload']));
     if (empty($_POST['work_start'])) {
         $work_start = "0000-00-00";
     } else {
         $work_start = $_POST['work_start'];
     }
     //start 'n' end
     $dateparts = explode("-", $work_start);
     $work_start = mktime(00, 00, 00, $dateparts[1], $dateparts[2], $dateparts[0]);
     $catId = intval($_POST['jobsCat']);
     $status = !empty($_POST['status']) ? intval($_POST['status']) : 0;
     $startDate = get_magic_quotes_gpc() ? strip_tags($_POST['startDate']) : addslashes(strip_tags($_POST['startDate']));
     $endDate = get_magic_quotes_gpc() ? strip_tags($_POST['endDate']) : addslashes(strip_tags($_POST['endDate']));
     $author = get_magic_quotes_gpc() ? strip_tags($_POST['author']) : addslashes(strip_tags($_POST['author']));
     $date = $this->_checkDate(date('H:i:s d.m.Y'));
     $dberr = false;
     $locset = '';
     //set of location that is associated with this job in the POST Data
     $locset_indb = '';
     //set of locations that is associated with this job in the db
     $rel_loc_jobs = '';
     //used to generate INSERT Statement
     foreach ($_POST['associated_locations'] as $value) {
         $locset[] = $value;
     }
     $query = "SELECT DISTINCT l.name as name,\n                  l.id as id\n                  FROM `" . DBPREFIX . "module_jobs_location` l\n                  LEFT JOIN `" . DBPREFIX . "module_jobs_rel_loc_jobs` as j on j.location=l.id\n                  WHERE j.job = {$id}";
     //Compare Post data and database
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         $dberr = true;
     }
     while (!$objResult->EOF && !$dberr) {
         if (in_array($objResult->fields['id'], $locset)) {
             $locset_indb[] = $objResult->fields['id'];
         } else {
             $query = "DELETE FROM `" . DBPREFIX . "module_jobs_rel_loc_jobs` WHERE job = " . $id . " AND location = " . $objResult->fields['id'];
             if (!$objDatabase->Execute($query)) {
                 $dberr = true;
             }
         }
         $objResult->MoveNext();
     }
     unset($value);
     if (count($locset) - count($locset_indb) > 0 && !$dberr) {
         foreach ($locset as $value) {
             if (!in_array($value, $locset_indb)) {
                 $rel_loc_jobs .= " ({$id},{$value}),";
             }
         }
         $rel_loc_jobs = substr_replace($rel_loc_jobs, "", -1);
         $query = "INSERT INTO `" . DBPREFIX . "module_jobs_rel_loc_jobs` (job,location) VALUES {$rel_loc_jobs} ";
         if (!$objDatabase->Execute($query)) {
             $dberr = true;
         }
     }
     $query = \SQL::update('module_jobs', array('date' => array('val' => $this->_checkDate($_POST['creation_date']), 'omitEmpty' => true), 'title' => $title, 'author' => $author, 'text' => array('val' => $text, 'omitEmpty' => true), 'workloc' => $workloc, 'workload' => $workload, 'work_start' => array('val' => $work_start, 'omitEmpty' => true), 'catid' => array('val' => $cat, 'omitEmpty' => true), 'lang' => array('val' => $this->langId, 'omitEmpty' => true), 'startdate' => array('val' => $startDate, 'omitEmpty' => true), 'enddate' => array('val' => $endDate, 'omitEmpty' => true), 'status' => array('val' => $status, 'omitEmpty' => true), 'userid' => array('val' => $userid, 'omitEmpty' => true), 'changelog' => array('val' => $date, 'omitEmpty' => true), 'catId' => array('val' => $catId, 'omitEmpty' => true))) . " WHERE id = {$id};";
     if (!$objDatabase->Execute($query) or $dberr) {
         $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'];
     } else {
         $this->createRSS();
         $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL'];
     }
 }
 /**
  * update the company size
  * 
  * @global object $objDatabase
  * @global array  $_ARRAYLANG
  * @param  array  $fields  post values
  * 
  * @return null
  */
 function modifyCompanySize($fields)
 {
     global $objDatabase, $_ARRAYLANG;
     $objTpl = $this->_objTpl;
     $objTpl->addBlockfile('CRM_SETTINGS_FILE', 'settings_block', 'module_' . $this->moduleNameLC . '_settings_modify_company_size.html');
     $id = isset($_GET['id']) ? $_GET['id'] : 0;
     //Get the company size
     $this->getCompanySize($id);
     //parse the placeholders
     $this->parseCompanySizePlaceholders();
     if ($_POST['save']) {
         if (!empty($id)) {
             //update
             $query = \SQL::update('module_' . $this->moduleNameLC . '_company_size', $fields, array('escape' => true)) . ' WHERE `id` = ' . $id;
         }
         $objResult = $objDatabase->Execute($query);
         if ($objResult) {
             $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_ENTRY_UPDATED_SUCCESS'];
             \Cx\Core\Csrf\Controller\Csrf::header("location:./index.php?cmd=" . $this->moduleName . "&act=settings&tpl=companySize");
             exit;
         } else {
             $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_CRM_ENTRY_UPDATE_ERROR'];
         }
     }
 }
Example #5
0
}
$rs = $ST->select("SELECT * FROM sc_pay_system WHERE name='paymaster'");
if ($rs->next() && $_GET) {
    $ps = new PSPaymaster(unserialize($rs->get('config')));
    if ($ps->checkSignature($_POST)) {
        //Данные прошли проверку
        $rs = $ST->select("SELECT * FROM sc_income \r\n\t\t\t\tWHERE \r\n\t\t\t\t\tpay_id=" . intval($_POST['LMI_PAYMENT_NO']) . "\r\n\t\t\t\t\tAND type='paymaster'");
        if ($rs->next()) {
            //перевод уже был, всё ок
            echo 'OK' . $_POST['LMI_PAYMENT_NO'];
            exit;
        } else {
            //если указан номер заявки
            if (isset($_POST['LMI_PAYMENT_NO'])) {
                $rs = $ST->select("SELECT * FROM sc_shop_order WHERE id=" . intval($_POST['LMI_PAYMENT_NO']));
                if ($rs->next()) {
                    if (floatval($_POST['LMI_PAYMENT_AMOUNT']) == $rs->getFloat('total_price')) {
                        $ST->update('sc_shop_order', array('pay_time' => date('Y-m-d H:i:s'), 'pay_status' => '1'), 'id=' . intval($_POST['LMI_PAYMENT_NO']));
                        //Оплата заказа
                        $ST->insert('sc_income', array('userid' => $rs->getInt('userid'), 'sum' => floatval($_POST['LMI_PAYMENT_AMOUNT']), 'type' => 'paymaster', 'description' => "Оплата заказа {$_POST['LMI_PAYMENT_NO']}", 'pay_id' => intval($_POST['LMI_PAYMENT_NO']), 'pay_string' => http_build_query($_POST)));
                        /*Уведомление*/
                        $mail = new Mail();
                        $mail->sendTemplateMail($CONFIG['MAIL'], 'notice_admin_user_buy', $rs->getRow());
                        //							$mail->sendTemplateMail($user['mail'],'notice_user_buy',$rs->getRow());
                    }
                }
            }
            echo 'OK' . $_POST['LMI_PAYMENT_NO'];
        }
    }
}
 public function update($data, $fields = false)
 {
     if (empty($data)) {
         return false;
     }
     $this->adjustDataAndFields($data, $fields);
     return parent::update($data, $fields);
 }
Example #7
0
<?php

if ($_GET['url'] && $_GET['r'] && $_GET['k'] && $_GET['p']) {
    include_once "config.php";
    include 'session.php';
    include_once "core/function.php";
    $ST = new SQL();
    $ST->connect(DB_HOST, DB_LOGIN, DB_PASSWORD, DB_BASE);
    if ($_GET['k'] == md5(session_id() . $_GET['r'] . $_GET['url'])) {
        $ST->update('sc_advertising', array('click=click+1'), "id=" . intval($_GET['p']));
    }
    header('Location: ' . $_GET['url']);
}
Example #8
0
if (date('Y-m-d', strtotime($last_start)) == date('Y-m-d')) {
    exit;
}
ini_set('log_errors', 'On');
ini_set('error_log', dirname(__FILE__) . '/php_errors_bonus.log');
include dirname(__FILE__) . "/../../config.php";
include dirname(__FILE__) . "/../../core/function.php";
set_time_limit(1000);
include_once dirname(__FILE__) . "/../../core/lib/SQL.class.php";
include_once dirname(__FILE__) . "/../../modules/shop/ShopBonus.class.php";
$ST = new SQL(DB_HOST, DB_LOGIN, DB_PASSWORD, DB_BASE);
$r = $ST->select("SELECT UPPER(name) AS name,value FROM sc_config ");
while ($r->next()) {
    if ($r->get('value')) {
        $CONFIG[$r->get('name')] = $r->get('value');
    }
}
$q = "SELECT * FROM sc_shop_order WHERE userid>0 AND order_status=3 AND stop_time BETWEEN '" . date('Y-m-d', strtotime('-1 day')) . "' AND '" . date('Y-m-d') . "'";
$rs = $ST->select($q);
while ($rs->next()) {
    $percent = ShopBonus::getBonusPercent($rs->getInt('userid'));
    $bonus = round($rs->getInt('price') / 20) * 20 / 100 * $percent * 10;
    $rs1 = $ST->select("SELECT * FROM sc_users WHERE u_id={$rs->getInt('userid')}");
    if ($rs1->next()) {
        $inc = array('userid' => $rs->getInt('userid'), 'sum' => $bonus, 'balance' => $bonus + $rs1->getInt('bonus'), 'type' => 'bonus', 'description' => 'Начисление бонуса', 'time' => date('Y-m-d H:i:s'));
        $ST->insert('sc_income', $inc);
        $ST->update('sc_users', array('bonus' => $bonus + $rs1->getInt('bonus')), "u_id={$rs->getInt('userid')}");
    }
}
file_put_contents(dirname(__FILE__) . '/bonus_last_start_log.txt', date('Y-m-d H:i:s') . "\n", FILE_APPEND);
file_put_contents(dirname(__FILE__) . '/bonus_last_start.txt', date('Y-m-d H:i:s'));
Example #9
0
 /**
  * 删除记录
  *
  * @param string $table
  * @param array $where
  * @return int
  */
 public static function delete($table, $where)
 {
     if (!is_array($where) && count($where) > 0) {
         return false;
     }
     $table = SQL::escape($table);
     $where = SQL::_parseWhere($where);
     $sql = "DELETE FROM `{$table}` WHERE {$where}";
     return SQL::update($sql);
 }
 /**
  * Save the event to the database
  *      
  * @param array $data
  * 
  * @return boolean true if saved successfully, false otherwise
  */
 function save($data)
 {
     global $objDatabase, $_LANGID, $_CONFIG, $objInit;
     parent::getSettings();
     if (empty($data['startDate']) || empty($data['endDate']) || empty($data['category']) || $data['seriesStatus'] == 1 && $data['seriesType'] == 2 && empty($data['seriesWeeklyDays'])) {
         return false;
     }
     foreach ($_POST['showIn'] as $key => $langId) {
         if (empty($_POST['title'][$langId]) && empty($_POST['title'][$_LANGID])) {
             return false;
         }
     }
     list($startDate, $strStartTime) = explode(' ', $data['startDate']);
     list($startHour, $startMin) = explode(':', $strStartTime);
     list($endDate, $strEndTime) = explode(' ', $data['endDate']);
     list($endHour, $endMin) = explode(':', $strEndTime);
     if ($data['all_day']) {
         list($startHour, $startMin) = array(0, 0);
         list($endHour, $endMin) = array(23, 59);
     }
     //event data
     $id = isset($data['copy']) && !empty($data['copy']) ? 0 : (isset($data['id']) ? intval($data['id']) : 0);
     $type = isset($data['type']) ? intval($data['type']) : 0;
     $startDate = date("Y-m-d H:i:s", parent::getDateTimestamp($startDate, intval($startHour), intval($startMin)));
     $endDate = date("Y-m-d H:i:s", parent::getDateTimestamp($endDate, intval($endHour), intval($endMin)));
     $google = isset($data['map'][$_LANGID]) ? intval($data['map'][$_LANGID]) : 0;
     $allDay = isset($data['all_day']) ? 1 : 0;
     $convertBBCode = $objInit->mode == 'frontend' && empty($id);
     $useCustomDateDisplay = isset($data['showDateSettings']) ? 1 : 0;
     $showStartDateList = isset($data['showStartDateList']) ? $data['showStartDateList'] : 0;
     $showEndDateList = isset($data['showEndDateList']) ? $data['showEndDateList'] : 0;
     if ($objInit->mode == 'backend') {
         // reset time values if "no time" is selected
         if ($data['showTimeTypeList'] == 0) {
             $showStartTimeList = 0;
             $showEndTimeList = 0;
         } else {
             $showStartTimeList = isset($data['showStartTimeList']) ? $data['showStartTimeList'] : '';
             $showEndTimeList = isset($data['showEndTimeList']) ? $data['showEndTimeList'] : '';
         }
         $showTimeTypeList = isset($data['showTimeTypeList']) ? $data['showTimeTypeList'] : '';
         $showStartDateDetail = isset($data['showStartDateDetail']) ? $data['showStartDateDetail'] : '';
         $showEndDateDetail = isset($data['showEndDateDetail']) ? $data['showEndDateDetail'] : '';
         // reset time values if "no time" is selected
         if ($data['showTimeTypeDetail'] == 0) {
             $showStartTimeDetail = 0;
             $showEndTimeDetail = 0;
         } else {
             $showStartTimeDetail = isset($data['showStartTimeDetail']) ? $data['showStartTimeDetail'] : '';
             $showEndTimeDetail = isset($data['showEndTimeDetail']) ? $data['showEndTimeDetail'] : '';
         }
         $showTimeTypeDetail = isset($data['showTimeTypeDetail']) ? $data['showTimeTypeDetail'] : '';
     } else {
         $showStartDateList = $this->arrSettings['showStartDateList'] == 1 ? 1 : 0;
         $showEndDateList = $this->arrSettings['showEndDateList'] == 1 ? 1 : 0;
         $showStartTimeList = $this->arrSettings['showStartTimeList'] == 1 ? 1 : 0;
         $showEndTimeList = $this->arrSettings['showEndTimeList'] == 1 ? 1 : 0;
         // reset time values if "no time" is selected
         if ($showStartTimeList == 1 || $showEndTimeList == 1) {
             $showTimeTypeList = 1;
         } else {
             $showStartTimeList = 0;
             $showEndTimeList = 0;
             $showTimeTypeList = 0;
         }
         $showStartDateDetail = $this->arrSettings['showStartDateDetail'] == 1 ? 1 : 0;
         $showEndDateDetail = $this->arrSettings['showEndDateDetail'] == 1 ? 1 : 0;
         $showStartTimeDetail = $this->arrSettings['showStartTimeDetail'] == 1 ? 1 : 0;
         $showEndTimeDetail = $this->arrSettings['showEndTimeDetail'] == 1 ? 1 : 0;
         // reset time values if "no time" is selected
         if ($showStartTimeDetail == 1 || $showEndTimeDetail == 1) {
             $showTimeTypeDetail = 1;
         } else {
             $showStartTimeDetail = 0;
             $showEndTimeDetail = 0;
             $showTimeTypeDetail = 0;
         }
     }
     $access = isset($data['access']) ? intval($data['access']) : 0;
     $priority = isset($data['priority']) ? intval($data['priority']) : 0;
     $placeMediadir = isset($data['placeMediadir']) ? intval($data['placeMediadir']) : 0;
     $hostMediadir = isset($data['hostMediadir']) ? intval($data['hostMediadir']) : 0;
     $price = isset($data['price']) ? contrexx_addslashes(contrexx_strip_tags($data['price'])) : 0;
     $link = isset($data['link']) ? contrexx_addslashes(contrexx_strip_tags($data['link'])) : '';
     $pic = isset($data['picture']) ? contrexx_addslashes(contrexx_strip_tags($data['picture'])) : '';
     $attach = isset($data['attachment']) ? contrexx_addslashes(contrexx_strip_tags($data['attachment'])) : '';
     $catId = isset($data['category']) ? intval($data['category']) : '';
     $showIn = isset($data['showIn']) ? contrexx_addslashes(contrexx_strip_tags(join(",", $data['showIn']))) : '';
     $invited_groups = isset($data['selectedGroups']) ? join(',', $data['selectedGroups']) : '';
     $invited_mails = isset($data['invitedMails']) ? contrexx_addslashes(contrexx_strip_tags($data['invitedMails'])) : '';
     $send_invitation = isset($data['sendInvitation']) ? intval($data['sendInvitation']) : 0;
     $invitationTemplate = isset($data['invitationEmailTemplate']) ? contrexx_input2db($data['invitationEmailTemplate']) : 0;
     $registration = isset($data['registration']) ? intval($data['registration']) : 0;
     $registration_form = isset($data['registrationForm']) ? intval($data['registrationForm']) : 0;
     $registration_num = isset($data['numSubscriber']) ? intval($data['numSubscriber']) : 0;
     $registration_notification = isset($data['notificationTo']) ? contrexx_addslashes(contrexx_strip_tags($data['notificationTo'])) : '';
     $email_template = isset($data['emailTemplate']) ? contrexx_input2db($data['emailTemplate']) : 0;
     $ticket_sales = isset($data['ticketSales']) ? intval($data['ticketSales']) : 0;
     $num_seating = isset($data['numSeating']) ? json_encode(explode(',', $data['numSeating'])) : '';
     $related_hosts = isset($data['selectedHosts']) ? $data['selectedHosts'] : '';
     $locationType = isset($data['eventLocationType']) ? (int) $data['eventLocationType'] : $this->arrSettings['placeData'];
     $hostType = isset($data['eventHostType']) ? (int) $data['eventHostType'] : $this->arrSettings['placeDataHost'];
     $place = isset($data['place']) ? contrexx_input2db(contrexx_strip_tags($data['place'])) : '';
     $street = isset($data['street']) ? contrexx_input2db(contrexx_strip_tags($data['street'])) : '';
     $zip = isset($data['zip']) ? contrexx_input2db(contrexx_strip_tags($data['zip'])) : '';
     $city = isset($data['city']) ? contrexx_input2db(contrexx_strip_tags($data['city'])) : '';
     $country = isset($data['country']) ? contrexx_input2db(contrexx_strip_tags($data['country'])) : '';
     $placeLink = isset($data['placeLink']) ? contrexx_input2db($data['placeLink']) : '';
     $placeMap = isset($data['placeMap']) ? contrexx_input2db($data['placeMap']) : '';
     $update_invitation_sent = $send_invitation == 1;
     if (!empty($placeLink)) {
         if (!preg_match('%^(?:ftp|http|https):\\/\\/%', $placeLink)) {
             $placeLink = "http://" . $placeLink;
         }
     }
     if ($objInit->mode == 'frontend') {
         $unique_id = intval($_REQUEST[self::MAP_FIELD_KEY]);
         if (!empty($unique_id)) {
             $picture = $this->_handleUpload('mapUpload', $unique_id);
             if (!empty($picture)) {
                 $placeMap = $picture;
             }
         }
     }
     $orgName = isset($data['organizerName']) ? contrexx_input2db($data['organizerName']) : '';
     $orgStreet = isset($data['organizerStreet']) ? contrexx_input2db($data['organizerStreet']) : '';
     $orgZip = isset($data['organizerZip']) ? contrexx_input2db($data['organizerZip']) : '';
     $orgCity = isset($data['organizerCity']) ? contrexx_input2db($data['organizerCity']) : '';
     $orgCountry = isset($data['organizerCountry']) ? contrexx_input2db($data['organizerCountry']) : '';
     $orgLink = isset($data['organizerLink']) ? contrexx_input2db($data['organizerLink']) : '';
     $orgEmail = isset($data['organizerEmail']) ? contrexx_input2db($data['organizerEmail']) : '';
     if (!empty($orgLink)) {
         if (!preg_match('%^(?:ftp|http|https):\\/\\/%', $orgLink)) {
             $orgLink = "http://" . $orgLink;
         }
     }
     // create thumb if not exists
     if (!file_exists(\Env::get('cx')->getWebsitePath() . "{$placeMap}.thumb")) {
         $objImage = new \ImageManager();
         $objImage->_createThumb(dirname(\Env::get('cx')->getWebsitePath() . "{$placeMap}") . "/", '', basename($placeMap), 180);
     }
     //frontend picture upload & thumbnail creation
     if ($objInit->mode == 'frontend') {
         $unique_id = intval($_REQUEST[self::PICTURE_FIELD_KEY]);
         $attachmentUniqueId = intval($_REQUEST[self::ATTACHMENT_FIELD_KEY]);
         if (!empty($unique_id)) {
             $picture = $this->_handleUpload('pictureUpload', $unique_id);
             if (!empty($picture)) {
                 //delete thumb
                 if (file_exists("{$this->uploadImgPath}{$pic}.thumb")) {
                     \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$pic}.thumb");
                 }
                 //delete image
                 if (file_exists("{$this->uploadImgPath}{$pic}")) {
                     \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$pic}");
                 }
                 $pic = $picture;
             }
         }
         if (!empty($attachmentUniqueId)) {
             $attachment = $this->_handleUpload('attachmentUpload', $attachmentUniqueId);
             if ($attachment) {
                 //delete file
                 if (file_exists("{$this->uploadImgPath}{$attach}")) {
                     \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$attach}");
                 }
                 $attach = $attachment;
             }
         }
     } else {
         // create thumb if not exists
         if (!file_exists(\Env::get('cx')->getWebsitePath() . "{$pic}.thumb")) {
             $objImage = new \ImageManager();
             $objImage->_createThumb(dirname(\Env::get('cx')->getWebsitePath() . "{$pic}") . "/", '', basename($pic), 180);
         }
     }
     $seriesStatus = isset($data['seriesStatus']) ? intval($data['seriesStatus']) : 0;
     //series pattern
     $seriesStatus = isset($data['seriesStatus']) ? intval($data['seriesStatus']) : 0;
     $seriesType = isset($data['seriesType']) ? intval($data['seriesType']) : 0;
     $seriesPatternCount = 0;
     $seriesPatternWeekday = 0;
     $seriesPatternDay = 0;
     $seriesPatternWeek = 0;
     $seriesPatternMonth = 0;
     $seriesPatternType = 0;
     $seriesPatternDouranceType = 0;
     $seriesPatternEnd = 0;
     $seriesExeptions = '';
     $seriesPatternEndDate = 0;
     if ($seriesStatus == 1) {
         if (!empty($data['seriesExeptions'])) {
             $exeptions = array();
             foreach ($data['seriesExeptions'] as $key => $exeptionDate) {
                 $exeptions[] = date("Y-m-d", parent::getDateTimestamp($exeptionDate, 23, 59));
             }
             sort($exeptions);
             $seriesExeptions = join(",", $exeptions);
         }
         switch ($seriesType) {
             case 1:
                 if ($seriesStatus == 1) {
                     $seriesPatternType = isset($data['seriesDaily']) ? intval($data['seriesDaily']) : 0;
                     if ($seriesPatternType == 1) {
                         $seriesPatternWeekday = 0;
                         $seriesPatternDay = isset($data['seriesDailyDays']) ? intval($data['seriesDailyDays']) : 0;
                     } else {
                         $seriesPatternWeekday = "1111100";
                         $seriesPatternDay = 0;
                     }
                     $seriesPatternWeek = 0;
                     $seriesPatternMonth = 0;
                     $seriesPatternCount = 0;
                 }
                 break;
             case 2:
                 if ($seriesStatus == 1) {
                     $seriesPatternWeek = isset($data['seriesWeeklyWeeks']) ? intval($data['seriesWeeklyWeeks']) : 0;
                     for ($i = 1; $i <= 7; $i++) {
                         if (isset($data['seriesWeeklyDays'][$i])) {
                             $weekdayPattern .= "1";
                         } else {
                             $weekdayPattern .= "0";
                         }
                     }
                     $seriesPatternWeekday = $weekdayPattern;
                     $seriesPatternCount = 0;
                     $seriesPatternDay = 0;
                     $seriesPatternMonth = 0;
                     $seriesPatternType = 0;
                 }
                 break;
             case 3:
                 if ($seriesStatus == 1) {
                     $seriesPatternType = isset($data['seriesMonthly']) ? intval($data['seriesMonthly']) : 0;
                     if ($seriesPatternType == 1) {
                         $seriesPatternMonth = isset($data['seriesMonthlyMonth_1']) ? intval($data['seriesMonthlyMonth_1']) : 0;
                         $seriesPatternDay = isset($data['seriesMonthlyDay']) ? intval($data['seriesMonthlyDay']) : 0;
                         $seriesPatternWeekday = 0;
                     } else {
                         $seriesPatternCount = isset($data['seriesMonthlyDayCount']) ? intval($data['seriesMonthlyDayCount']) : 0;
                         $seriesPatternMonth = isset($data['seriesMonthlyMonth_2']) ? intval($data['seriesMonthlyMonth_2']) : 0;
                         if ($seriesPatternMonth < 1) {
                             // the increment must be at least once a month, otherwise we will end up in a endless loop in the presence
                             $seriesPatternMonth = 1;
                         }
                         $seriesPatternWeekday = isset($data['seriesMonthlyWeekday']) ? $data['seriesMonthlyWeekday'] : '';
                         $seriesPatternDay = 0;
                     }
                     $seriesPatternWeek = 0;
                 }
                 break;
         }
         $seriesPatternDouranceType = isset($data['seriesDouranceType']) ? intval($data['seriesDouranceType']) : 0;
         switch ($seriesPatternDouranceType) {
             case 1:
                 $seriesPatternEnd = 0;
                 break;
             case 2:
                 $seriesPatternEnd = isset($data['seriesDouranceEvents']) ? intval($data['seriesDouranceEvents']) : 0;
                 break;
             case 3:
                 $seriesPatternEndDate = date("Y-m-d H:i:s", parent::getDateTimestamp($data['seriesDouranceDate'], 23, 59));
                 break;
         }
     }
     $formData = array('type' => $type, 'startdate' => $startDate, 'enddate' => $endDate, 'use_custom_date_display' => $useCustomDateDisplay, 'showStartDateList' => $showStartDateList, 'showEndDateList' => $showEndDateList, 'showStartTimeList' => $showStartTimeList, 'showEndTimeList' => $showEndTimeList, 'showTimeTypeList' => $showTimeTypeList, 'showStartDateDetail' => $showStartDateDetail, 'showEndDateDetail' => $showEndDateDetail, 'showStartTimeDetail' => $showStartTimeDetail, 'showEndTimeDetail' => $showEndTimeDetail, 'showTimeTypeDetail' => $showTimeTypeDetail, 'google' => $google, 'access' => $access, 'priority' => $priority, 'price' => $price, 'link' => $link, 'pic' => $pic, 'catid' => $catId, 'attach' => $attach, 'place_mediadir_id' => $placeMediadir, 'host_mediadir_id' => $hostMediadir, 'show_in' => $showIn, 'invited_groups' => $invited_groups, 'invited_mails' => $invited_mails, 'invitation_email_template' => json_encode($invitationTemplate), 'registration' => $registration, 'registration_form' => $registration_form, 'registration_num' => $registration_num, 'registration_notification' => $registration_notification, 'email_template' => json_encode($email_template), 'ticket_sales' => $ticket_sales, 'num_seating' => $num_seating, 'series_status' => $seriesStatus, 'series_type' => $seriesType, 'series_pattern_count' => $seriesPatternCount, 'series_pattern_weekday' => $seriesPatternWeekday, 'series_pattern_day' => $seriesPatternDay, 'series_pattern_week' => $seriesPatternWeek, 'series_pattern_month' => $seriesPatternMonth, 'series_pattern_type' => $seriesPatternType, 'series_pattern_dourance_type' => $seriesPatternDouranceType, 'series_pattern_end' => $seriesPatternEnd, 'series_pattern_end_date' => $seriesPatternEndDate, 'series_pattern_exceptions' => $seriesExeptions, 'all_day' => $allDay, 'location_type' => $locationType, 'host_type' => $hostType, 'place' => $place, 'place_id' => 0, 'place_street' => $street, 'place_zip' => $zip, 'place_city' => $city, 'place_country' => $country, 'place_link' => $placeLink, 'place_map' => $placeMap, 'org_name' => $orgName, 'org_street' => $orgStreet, 'org_zip' => $orgZip, 'org_city' => $orgCity, 'org_country' => $orgCountry, 'org_link' => $orgLink, 'org_email' => $orgEmail, 'invitation_sent' => $update_invitation_sent ? 1 : 0);
     if ($id != 0) {
         $query = \SQL::update("module_{$this->moduleTablePrefix}_event", $formData) . " WHERE id = '{$id}'";
         $objResult = $objDatabase->Execute($query);
         if ($objResult !== false) {
             $this->id = $id;
             $query = "DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_event_field\n                                WHERE event_id = '" . $id . "'";
             $objResult = $objDatabase->Execute($query);
             $query = "DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_event_host\n                                WHERE event_id = '" . $id . "'";
             $objResult = $objDatabase->Execute($query);
         } else {
             return false;
         }
     } else {
         $objFWUser = \FWUser::getFWUserObject();
         $objUser = $objFWUser->objUser;
         if ($objInit->mode == 'frontend') {
             $status = 1;
             $confirmed = $this->arrSettings['confirmFrontendEvents'] == 1 ? 0 : 1;
             $author = $objUser->login() ? intval($objUser->getId()) : 0;
         } else {
             $status = 0;
             $confirmed = 1;
             $author = intval($objUser->getId());
         }
         $formData['status'] = $status;
         $formData['confirmed'] = $confirmed;
         $formData['author'] = $author;
         $query = \SQL::insert("module_{$this->moduleTablePrefix}_event", $formData);
         $objResult = $objDatabase->Execute($query);
         if ($objResult !== false) {
             $id = intval($objDatabase->Insert_ID());
             $this->id = $id;
         } else {
             return false;
         }
     }
     if ($id != 0) {
         foreach ($data['showIn'] as $key => $langId) {
             $title = contrexx_addslashes(contrexx_strip_tags($data['title'][$langId]));
             $description = contrexx_addslashes($data['description'][$langId]);
             if ($convertBBCode) {
                 $description = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($data['description'][$langId], true);
             }
             $redirect = contrexx_addslashes($data['calendar-redirect'][$langId]);
             if ($type == 0) {
                 $redirect = '';
             } else {
                 $description = '';
             }
             $query = "INSERT INTO " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_event_field\n                            (`event_id`,`lang_id`,`title`, `description`,`redirect`)\n                          VALUES\n                            ('" . intval($id) . "','" . intval($langId) . "','" . $title . "','" . $description . "','" . $redirect . "')";
             $objResult = $objDatabase->Execute($query);
             if ($objResult === false) {
                 return false;
             }
         }
         if (!empty($related_hosts)) {
             foreach ($related_hosts as $key => $hostId) {
                 $query = "INSERT INTO " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_event_host\n                                      (`host_id`,`event_id`) \n                               VALUES ('" . intval($hostId) . "','" . intval($id) . "')";
                 $objResult = $objDatabase->Execute($query);
             }
         }
     }
     if ($send_invitation == 1) {
         $objMailManager = new \Cx\Modules\Calendar\Controller\CalendarMailManager();
         foreach ($invitationTemplate as $templateId) {
             $objMailManager->sendMail(intval($id), \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_INVITATION, null, $templateId);
         }
     }
     return true;
 }
Example #11
0
 /**
  * add /edit task
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 public function _modifyTask()
 {
     global $_ARRAYLANG, $objDatabase, $objJs, $objFWUser;
     \JS::registerCSS("modules/Crm/View/Style/contact.css");
     if (gettype($objFWUser) === 'NULL') {
         $objFWUser = \FWUser::getFWUserObject();
     }
     $objtpl = $this->_objTpl;
     $_SESSION['pageTitle'] = empty($_GET['id']) ? $_ARRAYLANG['TXT_CRM_ADDTASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'];
     $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_addtasks.html');
     $objtpl->setGlobalVariable("MODULE_NAME", $this->moduleName);
     $settings = $this->getSettings();
     $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
     $date = date('Y-m-d H:i:s');
     $title = isset($_POST['taskTitle']) ? contrexx_input2raw($_POST['taskTitle']) : '';
     $type = isset($_POST['taskType']) ? (int) $_POST['taskType'] : 0;
     $customer = isset($_REQUEST['customerId']) ? (int) $_REQUEST['customerId'] : '';
     $duedate = isset($_POST['date']) ? $_POST['date'] : $date;
     $assignedto = isset($_POST['assignedto']) ? intval($_POST['assignedto']) : 0;
     $description = isset($_POST['description']) ? contrexx_input2raw($_POST['description']) : '';
     $notify = isset($_POST['notify']);
     $taskId = isset($_REQUEST['searchType']) ? intval($_REQUEST['searchType']) : 0;
     $taskTitle = isset($_REQUEST['searchTitle']) ? contrexx_input2raw($_REQUEST['searchTitle']) : '';
     $redirect = isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : base64_encode('&act=task');
     // check permission
     if (!empty($id)) {
         $objResult = $objDatabase->Execute("SELECT `added_by`,\n                                                       `assigned_to`\n                                                    FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task`\n                                                 WHERE `id` = '{$id}'\n                                               ");
         $added_user = (int) $objResult->fields['added_by'];
         $assigned_user = (int) $objResult->fields['assigned_to'];
         if ($objResult) {
             list($task_edit_permission) = $this->getTaskPermission($added_user, $assigned_user);
             if (!$task_edit_permission) {
                 \Permission::noAccess();
             }
         }
     }
     if (isset($_POST['addtask'])) {
         if (!empty($id)) {
             if ($objFWUser->objUser->getAdminStatus() || $added_user == $objFWUser->objUser->getId() || $assigned_user == $assignedto) {
                 $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'description' => $description);
                 $query = \SQL::update("module_{$this->moduleNameLC}_task", $fields, array('escape' => true)) . " WHERE `id` = {$id}";
                 $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_UPDATE_MESSAGE'];
             } else {
                 $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE_ERR'];
             }
         } else {
             $addedDate = date('Y-m-d H:i:s');
             $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'added_by' => $objFWUser->objUser->getId(), 'added_date_time' => $addedDate, 'task_status' => '0', 'description' => $description);
             $query = \SQL::insert("module_{$this->moduleNameLC}_task", $fields, array('escape' => true));
             $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_OK_MESSAGE'];
         }
         $db = $objDatabase->Execute($query);
         if ($db) {
             if ($notify) {
                 $cx = \Cx\Core\Core\Controller\Cx::instanciate();
                 $id = !empty($id) ? $id : $objDatabase->INSERT_ID();
                 $info['substitution'] = array('CRM_ASSIGNED_USER_NAME' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($assignedto)), 'CRM_ASSIGNED_USER_EMAIL' => $objFWUser->objUser->getUser($assignedto)->getEmail(), 'CRM_DOMAIN' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath(), 'CRM_TASK_NAME' => $title, 'CRM_TASK_LINK' => "<a href='" . ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}'>{$title}</a>", 'CRM_TASK_URL' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}", 'CRM_TASK_DUE_DATE' => $duedate, 'CRM_TASK_CREATED_USER' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objFWUser->objUser->getId())), 'CRM_TASK_DESCRIPTION_TEXT_VERSION' => contrexx_html2plaintext($description), 'CRM_TASK_DESCRIPTION_HTML_VERSION' => $description);
                 //setting email template lang id
                 $availableMailTempLangAry = $this->getActiveEmailTemLangId('Crm', CRM_EVENT_ON_TASK_CREATED);
                 $availableLangId = $this->getEmailTempLang($availableMailTempLangAry, $objFWUser->objUser->getUser($assignedto)->getEmail());
                 $info['lang_id'] = $availableLangId;
                 $dispatcher = CrmEventDispatcher::getInstance();
                 $dispatcher->triggerEvent(CRM_EVENT_ON_TASK_CREATED, null, $info);
             }
             \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . base64_decode($redirect));
             exit;
         }
     } elseif (!empty($id)) {
         $objValue = $objDatabase->Execute("SELECT task_id,\n                                                            task_title,\n                                                            task_type_id,\n                                                            due_date,\n                                                            assigned_to,\n                                                            description,\n                                                            c.id,\n                                                            c.customer_name,\n                                                            c.contact_familyname\n                                                       FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task` AS t\n                                                       LEFT JOIN `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` AS c\n                                                            ON t.customer_id = c.id\n                                                       WHERE t.id='{$id}'");
         $title = $objValue->fields['task_title'];
         $type = $objValue->fields['task_type_id'];
         $customer = $objValue->fields['id'];
         $customerName = !empty($objValue->fields['customer_name']) ? $objValue->fields['customer_name'] . " " . $objValue->fields['contact_familyname'] : '';
         $duedate = $objValue->fields['due_date'];
         $assignedto = $objValue->fields['assigned_to'];
         $description = $objValue->fields['description'];
         $taskAutoId = $objValue->fields['task_id'];
     }
     $this->_getResourceDropDown('Members', $assignedto, $settings['emp_default_user_group']);
     $this->taskTypeDropDown($objtpl, $type);
     if (!empty($customer)) {
         // Get customer Name
         $objCustomer = $objDatabase->Execute("SELECT customer_name, contact_familyname  FROM `" . DBPREFIX . "module_crm_contacts` WHERE id = {$customer}");
         $customerName = $objCustomer->fields['customer_name'] . " " . $objCustomer->fields['contact_familyname'];
     }
     $objtpl->setVariable(array('CRM_LOGGED_USER_ID' => $objFWUser->objUser->getId(), 'CRM_TASK_AUTOID' => contrexx_raw2xhtml($taskAutoId), 'CRM_TASK_ID' => (int) $id, 'CRM_TASKTITLE' => contrexx_raw2xhtml($title), 'CRM_DUE_DATE' => contrexx_raw2xhtml($duedate), 'CRM_CUSTOMER_ID' => intval($customer), 'CRM_CUSTOMER_NAME' => contrexx_raw2xhtml($customerName), 'CRM_TASK_DESC' => new \Cx\Core\Wysiwyg\Wysiwyg('description', contrexx_raw2xhtml($description)), 'CRM_BACK_LINK' => base64_decode($redirect), 'TXT_CRM_ADD_TASK' => empty($id) ? $_ARRAYLANG['TXT_CRM_ADD_TASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'], 'TXT_CRM_TASK_ID' => $_ARRAYLANG['TXT_CRM_TASK_ID'], 'TXT_CRM_TASK_TITLE' => $_ARRAYLANG['TXT_CRM_TASK_TITLE'], 'TXT_CRM_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_TASK_TYPE'], 'TXT_CRM_SELECT_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_SELECT_TASK_TYPE'], 'TXT_CRM_CUSTOMER_NAME' => $_ARRAYLANG['TXT_CRM_CUSTOMER_NAME'], 'TXT_CRM_TASK_DUE_DATE' => $_ARRAYLANG['TXT_CRM_TASK_DUE_DATE'], 'TXT_CRM_TASK_RESPONSIBLE' => $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE'], 'TXT_CRM_SELECT_MEMBER_NAME' => $_ARRAYLANG['TXT_CRM_SELECT_MEMBER_NAME'], 'TXT_CRM_OVERVIEW' => $_ARRAYLANG['TXT_CRM_OVERVIEW'], 'TXT_CRM_TASK_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_TASK_DESCRIPTION'], 'TXT_CRM_FIND_COMPANY_BY_NAME' => $_ARRAYLANG['TXT_CRM_FIND_COMPANY_BY_NAME'], 'TXT_CRM_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], 'TXT_CRM_BACK' => $_ARRAYLANG['TXT_CRM_BACK'], 'TXT_CRM_NOTIFY' => $_ARRAYLANG['TXT_CRM_NOTIFY'], 'TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT' => $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT']));
 }
Example #12
0
 /**
  * Builds the different types of SQL queries
  * This uses the SQL class to build stuff.
  *
  * @param string $type (select, update, insert)
  * @return string The final query
  */
 public function build($type)
 {
     $sql = new SQL($this->db);
     switch ($type) {
         case 'select':
             return $sql->select(array('table' => $this->table, 'columns' => $this->select, 'join' => $this->join, 'distinct' => $this->distinct, 'where' => $this->where, 'group' => $this->group, 'having' => $this->having, 'order' => $this->order, 'offset' => $this->offset, 'limit' => $this->limit));
         case 'update':
             return $sql->update(array('table' => $this->table, 'where' => $this->where, 'values' => $this->values));
         case 'insert':
             return $sql->insert(array('table' => $this->table, 'values' => $this->values));
         case 'delete':
             return $sql->delete(array('table' => $this->table, 'where' => $this->where));
     }
 }
Example #13
0
 /**
  * the upload is finished
  * rewrite the names
  * write the uploaded files to the database
  *
  * @param string     $tempPath    the temporary file path
  * @param string     $tempWebPath the temporary file path which is accessable by web browser
  * @param array      $data        the data which are attached by uploader init method
  * @param integer    $uploadId    the upload id
  * @param array      $fileInfos   the file infos  
  * 
  * @return array the target paths
  */
 public static function proPhotoUploadFinished($tempPath, $tempWebPath, $data, $uploadId, $fileInfos, $response)
 {
     global $objDatabase, $objFWUser;
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $depositionTarget = $cx->getWebsiteImagesCrmProfilePath() . '/';
     //target folder
     $h = opendir($tempPath);
     if ($h) {
         while (false != ($file = readdir($h))) {
             $info = pathinfo($file);
             //skip . and ..
             if ($file == '.' || $file == '..') {
                 continue;
             }
             if ($file != '..' && $file != '.') {
                 //do not overwrite existing files.
                 $prefix = '';
                 while (file_exists($depositionTarget . $prefix . $file)) {
                     if (empty($prefix)) {
                         $prefix = 0;
                     }
                     $prefix++;
                 }
                 // move file
                 try {
                     $objFile = new \Cx\Lib\FileSystem\File($tempPath . '/' . $file);
                     $objFile->copy($depositionTarget . $prefix . $file, false);
                     // create thumbnail
                     if (empty($objImage)) {
                         $objImage = new \ImageManager();
                     }
                     $imageName = trim($prefix . $file);
                     $objImage->_createThumbWhq($cx->getWebsiteImagesCrmProfilePath() . '/', $cx->getWebsiteImagesCrmProfileWebPath() . '/', $imageName, 40, 40, 70, '_40X40.thumb');
                     $objImage->_createThumbWhq($cx->getWebsiteImagesCrmProfilePath() . '/', $cx->getWebsiteImagesCrmProfileWebPath() . '/', $imageName, 121, 160, 70);
                     // write the uploaded files into database
                     $fields = array('profile_picture' => $imageName);
                     $sql = \SQL::update("module_crm_contacts", $fields, array('escape' => true)) . " WHERE `id` = {$data[0]}";
                     $objDatabase->Execute($sql);
                     $accountId = $objDatabase->getOne("SELECT user_account FROM `" . DBPREFIX . "module_crm_contacts` WHERE id = {$data[0]}");
                     if (!empty($accountId) && !empty($imageName)) {
                         $objUser = $objFWUser->objUser->getUser($accountId);
                         if (!file_exists($cx->getWebsiteImagesAccessProfilePath() . '/' . $imageName)) {
                             $file = $cx->getWebsiteImagesCrmProfilePath() . '/';
                             if (($imageName = self::moveUploadedImageInToPlace($objUser, $file . $imageName, $imageName, true)) == true) {
                                 // create thumbnail
                                 $objImage = new \ImageManager();
                                 $objImage->_createThumbWhq($cx->getWebsiteImagesAccessProfilePath() . '/', $cx->getWebsiteImagesAccessProfileWebPath() . '/', $imageName, 80, 60, 90);
                                 $objUser->setProfile(array('picture' => array(0 => $imageName)));
                                 $objUser->store();
                             }
                         }
                     }
                 } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                     \DBG::msg($e->getMessage());
                 }
             }
             $arrFiles[] = $file;
         }
         closedir($h);
     }
     // return web- and filesystem path. files will be moved there.
     return array($tempPath, $tempWebPath);
 }
Example #14
0
         $params[substr($key, 3)] = $val;
     }
 }
 $ps->params = $params;
 if ($ps->checkSignature($_GET['SignatureValue'])) {
     //Данные прошли проверку
     //if($ps->params['Type']=='balance'){
     $rs = $ST->select("SELECT * FROM sc_income \r\n\t\t\t\tWHERE \r\n\t\t\t\t\tuserid=" . intval($ps->params['UserId']) . "\r\n\t\t\t\t\tAND pay_id=" . intval($ps->InvId) . "\r\n\t\t\t\t\tAND type='robokassa'");
     if ($rs->next()) {
         //перевод уже был, всё ок
         echo 'OK' . $_GET['InvId'];
         exit;
     } else {
         if ($ps->params['Type'] == 'balance') {
             //пополним баланс
             $ST->update('sc_users', array('balance=balance+' . floatval($ps->OutSum)), "u_id=" . intval($ps->params['UserId']));
             $rs = $ST->execute("SELECT balance FROM sc_users WHERE u_id=" . intval($ps->params['UserId']));
             if ($rs->next()) {
                 $ST->insert('sc_income', array('userid' => intval($ps->params['UserId']), 'sum' => floatval($ps->OutSum), 'balance' => floatval($rs->getFloat('balance')), 'type' => 'robokassa', 'description' => 'Приход с робокассы', 'pay_id' => intval($ps->InvId), 'pay_string' => $_SERVER['QUERY_STRING']));
             }
         }
         //если указан номер заявки
         if (isset($ps->params['OrderId'])) {
             $rs = $ST->select("SELECT * FROM sc_users WHERE u_id=" . intval($ps->params['UserId']));
             if ($rs->next()) {
                 $user = $rs->getRow();
                 //						$rs=$ST->execute("SELECT * FROM sc_cc_order WHERE userid=".intval($ps->params['UserId'])." AND id=".intval($ps->params['OrderId']));
                 $rs = $ST->select("SELECT * FROM sc_shop_order WHERE userid=" . intval($ps->params['UserId']) . " AND id=" . intval($ps->params['OrderId']));
                 if ($rs->next() && floatval($ps->OutSum) >= $rs->getInt('total_price')) {
                     //							$ST->update('sc_users',array('balance=balance-'.$rs->getInt('summ')),"u_id=".intval($ps->params['UserId']));
                     $ST->update('sc_shop_order', array('pay_time' => date('Y-m-d H:i:s'), 'pay_status' => 'ok'), 'id=' . intval($ps->params['OrderId']));
Example #15
0
<?php

require_once '../config.php';
require_once '../core/lib/SQL.class.php';
require_once '../core/lib/PSPayonline.class.php';
file_put_contents('log.txt', date("Y-m-d H:i:s") . " {$_SERVER['REQUEST_URI']}\r\n", FILE_APPEND);
//exit;
$ST = new SQL();
$ST->connect(DB_HOST, DB_LOGIN, DB_PASSWORD, DB_BASE);
$rs = $ST->select("SELECT * FROM sc_pay_system WHERE name='payonline'");
if ($rs->next() && $_GET) {
    $ps = new PSPayonline(unserialize($rs->get('config')));
    $ps->OrderId = $_GET['OrderId'];
    $ps->Amount = $_GET['Amount'];
    $ps->Currency = $_GET['Currency'];
    $ps->TransactionID = $_GET['TransactionID'];
    $ps->DateTime = $_GET['DateTime'];
    if (isset($_GET['ValidUntil'])) {
        $ps->ValidUntil = $_GET['ValidUntil'];
    }
    if ($ps->checkSignature($_GET['SecurityKey']) && isset($_GET['UserId']) && isset($_GET['OrderNum'])) {
        $ST->update('sc_shop_order', array('pay_status' => 'paid', 'pay_time' => date('Y-m-d H:i:s'), 'pay_system' => 'payonline'), "id='" . intval($_GET['OrderNum']) . "'");
        //OrderNum доп параметр
    }
}
Example #16
0
         } elseif ($ps->operation == 'payment' && !empty($_GET['id_payment'])) {
             $ps->id_payment = $_GET['id_payment'];
             $ps->date = $_GET['date'];
             //1. Смотрим, был ли платёж
             $rs1 = $ST->select("SELECT * FROM sc_pay_income WHERE ext_id={$ps->id_payment}");
             if ($rs1->next()) {
                 $ps->ext_id_payment = $rs1->get('id');
                 $ps->date = date('YmdHis', strtotime($rs1->get('date')));
                 $ps->error = 516;
                 //Дублирование платежа
                 $ps->fatal = true;
                 echo $ps->response();
                 exit;
             } else {
                 $ps->ext_id_payment = $ST->insert('sc_pay_income', array('ext_id' => $ps->id_payment, 'order_id' => $rs->get('id'), 'date' => $date = date('Y-m-d H:i:s'), 'sum' => $ps->sum, 'operator' => 'comepay'));
                 $ST->update('sc_shop_order', array('pay_system' => 'comepay', 'pay_time' => date('Y-m-d H:i:s'), 'pay_status' => 'paid', 'pay_summ=pay_summ+' . $ps->sum), "id=" . $rs->get('id'));
                 $ps->date = date('YmdHis', strtotime($date));
                 $ps->fatal = true;
                 echo $ps->response();
                 exit;
                 //Ура! Заплатили!
             }
         }
     }
 } else {
     $ps->error = 500;
     //Неверный номер абонента
     $ps->fatal = true;
     echo $ps->response();
     exit;
 }
Example #17
0
 public function setUser($id)
 {
     $this->user = new User($id);
     $statement = new Database(SQL::update('user', 'sessions', 'id=:id'), array(':id' => $this->id, ':user' => $this->user->id));
     if ($id) {
         $statement = new Database(SQL::insert('time,user', 'user_logins', 'id=:id'), array(':time' => time(), ':user' => $id));
     }
 }
 function _updateRecipient($recipientAttributeStatus, $id, $email, $uri, $sex, $salutation, $title, $lastname, $firstname, $position, $company, $industry_sector, $address, $zip, $city, $country, $phone_office, $phone_private, $phone_mobile, $fax, $notes, $birthday, $status, $arrLists, $language)
 {
     global $objDatabase;
     $query = \SQL::update('module_newsletter_user', array('email' => contrexx_addslashes($email), 'uri' => array('val' => contrexx_addslashes($uri), 'omitEmpty' => !$recipientAttributeStatus['recipient_website']['active']), 'sex' => array('val' => contrexx_addslashes($sex), 'omitEmpty' => !$recipientAttributeStatus['recipient_sex']['active']), 'salutation' => array('val' => contrexx_addslashes($salutation), 'omitEmpty' => !$recipientAttributeStatus['recipient_salutation']['active']), 'title' => array('val' => contrexx_addslashes($title), 'omitEmpty' => !$recipientAttributeStatus['recipient_title']['active']), 'lastname' => array('val' => contrexx_addslashes($lastname), 'omitEmpty' => !$recipientAttributeStatus['recipient_lastname']['active']), 'firstname' => array('val' => contrexx_addslashes($firstname), 'omitEmpty' => !$recipientAttributeStatus['recipient_firstname']['active']), 'position' => array('val' => contrexx_addslashes($position), 'omitEmpty' => !$recipientAttributeStatus['recipient_position']['active']), 'company' => array('val' => contrexx_addslashes($company), 'omitEmpty' => !$recipientAttributeStatus['recipient_company']['active']), 'industry_sector' => array('val' => contrexx_addslashes($industry_sector), 'omitEmpty' => !$recipientAttributeStatus['recipient_industry']['active']), 'address' => array('val' => contrexx_addslashes($address), 'omitEmpty' => !$recipientAttributeStatus['recipient_address']['active']), 'zip' => array('val' => contrexx_addslashes($zip), 'omitEmpty' => !$recipientAttributeStatus['recipient_zip']['active']), 'city' => array('val' => contrexx_addslashes($city), 'omitEmpty' => !$recipientAttributeStatus['recipient_city']['active']), 'country_id' => array('val' => contrexx_addslashes($country), 'omitEmpty' => !$recipientAttributeStatus['recipient_country']['active']), 'phone_office' => array('val' => contrexx_addslashes($phone_office), 'omitEmpty' => !$recipientAttributeStatus['recipient_phone']['active']), 'phone_private' => array('val' => contrexx_addslashes($phone_private), 'omitEmpty' => !$recipientAttributeStatus['recipient_private']['active']), 'phone_mobile' => array('val' => contrexx_addslashes($phone_mobile), 'omitEmpty' => !$recipientAttributeStatus['recipient_mobile']['active']), 'fax' => array('val' => contrexx_addslashes($fax), 'omitEmpty' => !$recipientAttributeStatus['recipient_fax']['active']), 'notes' => !$notes ? '' : contrexx_addslashes($notes), 'birthday' => array('val' => contrexx_addslashes($birthday), 'omitEmpty' => !$recipientAttributeStatus['recipient_birthday']['active']), 'status' => intval($status), 'language' => intval($language))) . "WHERE id=" . $id;
     if (!$objDatabase->Execute($query)) {
         return false;
     }
     return $this->_setRecipientLists($id, $arrLists);
 }
Example #19
0
 /**
  * Save a record
  * 
  * @global ADO Connection $objDatabase
  * 
  * @return Boolean
  */
 function save()
 {
     global $objDatabase;
     $fields = array('customer_id' => isset($this->customerId) ? $this->customerId : '', 'customer_type' => isset($this->customerType) ? (int) $this->customerType : 0, 'customer_name' => isset($this->customerName) ? $this->customerName : '', 'customer_addedby' => isset($this->addedUser) ? (int) $this->addedUser : 1, 'company_size' => isset($this->companySize) ? $this->companySize : 0, 'customer_currency' => isset($this->currency) ? (int) $this->currency : 0, 'contact_familyname' => isset($this->family_name) ? $this->family_name : '', 'contact_role' => isset($this->contact_role) ? $this->contact_role : '', 'contact_customer' => isset($this->contact_customer) ? (int) $this->contact_customer : '', 'contact_language' => isset($this->contact_language) ? (int) $this->contact_language : '', 'notes' => isset($this->notes) ? $this->notes : '', 'industry_type' => isset($this->industryType) ? $this->industryType : '', 'contact_type' => isset($this->contactType) ? (int) $this->contactType : '', 'user_account' => isset($this->account_id) ? (int) $this->account_id : '', 'gender' => isset($this->contact_gender) ? (int) $this->contact_gender : '', 'profile_picture' => array('val' => isset($this->profile_picture) && !empty($this->profile_picture) ? $this->profile_picture : null, 'omitEmpty' => true), 'email_delivery' => isset($this->emailDelivery) ? contrexx_input2int($this->emailDelivery) : 1);
     if (!isset($this->id) || empty($this->id)) {
         $fields['datasource'] = isset($this->datasource) ? $this->datasource : '';
         $fields['added_date'] = date('Y-m-d H:i:s');
         \Env::get('cx')->getEvents()->triggerEvent('model/prePersist', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         $query = \SQL::insert("module_{$this->moduleName}_contacts", $fields, array('escape' => true));
     } else {
         \Env::get('cx')->getEvents()->triggerEvent('model/preUpdate', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         $query = \SQL::update("module_{$this->moduleName}_contacts", $fields, array('escape' => true)) . " WHERE `id` = {$this->id}";
     }
     //echo $query; exit();
     if ($objDatabase->execute($query)) {
         if (!isset($this->id) || empty($this->id)) {
             $this->id = $objDatabase->INSERT_ID();
             \Env::get('cx')->getEvents()->triggerEvent('model/postPersist', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         } else {
             if (!empty($this->id)) {
                 \Env::get('cx')->getEvents()->triggerEvent('model/postUpdate', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
             }
         }
         return true;
     }
     return false;
 }
 function updatePosition()
 {
     global $objDatabase;
     $query = \SQL::update('module_survey_surveyQuestions', array('pos' => $this->position), array('escape' => true)) . " WHERE `id` = {$this->id}";
     $objDatabase->Execute($query);
 }
 /**
  * Check the argument and save the field values to corresponding DB
  *
  * @param String $tableName Table name
  * @param Array  $values    Conditions
  * @param Array  $fields    Field values
  *
  * @return null
  */
 function checkRecordStoreTODB($tableName = '', $values = array(), $fields = array())
 {
     global $objDatabase;
     if (!empty($tableName) && !empty($fields)) {
         $objRecordExist = $objDatabase->getOne("SELECT id FROM `" . DBPREFIX . "{$tableName}` WHERE {$values['0']} = '" . $values[1] . "' AND contact_id = {$values[2]}");
         if ($objRecordExist && !empty($objRecordExist)) {
             $query = \SQL::update($tableName, $fields, array('escape' => true)) . " WHERE `id` = {$objRecordExist}";
         } else {
             $query = \SQL::insert($tableName, $fields, array('escape' => true));
         }
         $objDatabase->execute($query);
     }
 }
Example #22
0
 /**
  * Adding Crm Contact and link it with crm company if possible
  *
  * @param Array $arrFormData form data's
  * @param int $userAccountId
  * @param int $frontendLanguage
  * @global <object> $objDatabase
  * @global int $_LANGID
  *
  */
 function setContactPersonProfile($arrFormData = array(), $userAccountId = 0, $frontendLanguage)
 {
     global $objDatabase, $_LANGID;
     $this->contact = new \Cx\Modules\Crm\Model\Entity\CrmContact();
     if (!empty($userAccountId)) {
         $userExists = $objDatabase->Execute("SELECT id FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` WHERE user_account = {$userAccountId}");
         if ($userExists && $userExists->RecordCount()) {
             $id = (int) $userExists->fields['id'];
             $this->contact->load($id);
             $this->contact->customerName = !empty($arrFormData['firstname'][0]) ? contrexx_input2raw($arrFormData['firstname'][0]) : '';
             $this->contact->family_name = !empty($arrFormData['lastname'][0]) ? contrexx_input2raw($arrFormData['lastname'][0]) : '';
             $this->contact->contact_language = !empty($frontendLanguage) ? (int) $frontendLanguage : $_LANGID;
             $this->contact->contact_gender = !empty($arrFormData['gender'][0]) ? $arrFormData['gender'][0] == 'gender_female' ? 1 : ($arrFormData['gender'][0] == 'gender_male' ? 2 : '') : '';
             $this->contact->contactType = 2;
             $this->contact->datasource = 2;
             $this->contact->account_id = $userAccountId;
             //set profile picture
             if (!empty($arrFormData['picture'][0])) {
                 $picture = $arrFormData['picture'][0];
                 $cx = \Cx\Core\Core\Controller\Cx::instanciate();
                 if (!file_exists($cx->getWebsiteImagesCrmProfilePath() . '/' . $picture)) {
                     $file = $cx->getWebsiteImagesAccessProfilePath() . '/';
                     $newFile = $cx->getWebsiteImagesCrmProfilePath() . '/';
                     if (copy($file . $picture, $newFile . $picture)) {
                         if ($this->createThumbnailOfPicture($picture)) {
                             $this->contact->profile_picture = $picture;
                         }
                     }
                 }
             } else {
                 $this->contact->profile_picture = 'profile_person_big.png';
             }
             // save current setting values, so we can switch back to them after we got our used settings out of database
             $prevSection = \Cx\Core\Setting\Controller\Setting::getCurrentSection();
             $prevGroup = \Cx\Core\Setting\Controller\Setting::getCurrentGroup();
             $prevEngine = \Cx\Core\Setting\Controller\Setting::getCurrentEngine();
             \Cx\Core\Setting\Controller\Setting::init('Crm', 'config');
             if ($arrFormData["company"][0] != "") {
                 $crmCompany = new \Cx\Modules\Crm\Model\Entity\CrmContact();
                 if ($this->contact->contact_customer != 0) {
                     $crmCompany->load($this->contact->contact_customer);
                 }
                 $crmCompany->customerName = $arrFormData["company"][0];
                 $crmCompany->contactType = 1;
                 $customerType = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_type', 'Crm')][0];
                 if ($customerType !== false) {
                     $crmCompany->customerType = $customerType;
                 }
                 $companySize = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_company_size', 'Crm')][0];
                 if ($companySize !== false) {
                     $crmCompany->companySize = $companySize;
                 }
                 $industryType = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_industry_type', 'Crm')][0];
                 if ($industryType !== false) {
                     $crmCompany->industryType = $industryType;
                 }
                 if (isset($arrFormData["phone_office"])) {
                     $crmCompany->phone = $arrFormData["phone_office"];
                 }
                 // store/update the company profile
                 $crmCompany->save();
                 // setting & storing the primary email address must be done after
                 // the company has been saved for the case where the company is
                 // being added as a new object without having an ID yet
                 if (empty($crmCompany->email)) {
                     $crmCompany->email = $this->contact->email;
                     $crmCompany->storeEMail();
                 }
                 $this->contact->contact_customer = $crmCompany->id;
             }
             if ($this->contact->save()) {
                 // insert website
                 if (!empty($arrFormData['website'][0])) {
                     $webExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'");
                     $fields = array('url' => $arrFormData['website'][0], 'url_profile' => '1', 'is_primary' => '1', 'contact_id' => $this->contact->id);
                     if ($webExists) {
                         $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true)) . " WHERE is_primary = '1' AND `contact_id` = {$this->contact->id}";
                     } else {
                         $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true));
                     }
                     $db = $objDatabase->Execute($query);
                 }
                 //insert address
                 if (!empty($arrFormData['address'][0]) || !empty($arrFormData['city'][0]) || !empty($arrFormData['zip'][0]) || !empty($arrFormData['country'][0])) {
                     $addressExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'");
                     $country = \Cx\Core\Country\Controller\Country::getById($arrFormData['country'][0]);
                     if ($addressExists && $addressExists->RecordCount()) {
                         $query = "UPDATE `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` SET\n                                    address      = '" . contrexx_input2db($arrFormData['address'][0]) . "',\n                                    city         = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n                                    zip          = '" . contrexx_input2db($arrFormData['zip'][0]) . "',\n                                    country      = '" . $country['name'] . "',\n                                    Address_Type = '2'\n                                 WHERE is_primary   = '1' AND contact_id   = '{$this->contact->id}'";
                     } else {
                         $query = "INSERT INTO `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` SET\n                                    address      = '" . contrexx_input2db($arrFormData['address'][0]) . "',\n                                    city         = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n                                    state        = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n                                    zip          = '" . contrexx_input2db($arrFormData['zip'][0]) . "',\n                                    country      = '" . $country['name'] . "',\n                                    Address_Type = '2',\n                                    is_primary   = '1',\n                                    contact_id   = '{$this->contact->id}'";
                     }
                     $objDatabase->Execute($query);
                 }
                 // insert Phone
                 $contactPhone = array();
                 if (!empty($arrFormData['phone_office'][0])) {
                     $phoneExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_phone` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'");
                     $fields = array('phone' => $arrFormData['phone_office'][0], 'phone_type' => '1', 'is_primary' => '1', 'contact_id' => $this->contact->id);
                     if ($phoneExists && $phoneExists->RecordCount()) {
                         $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_phone", $fields, array('escape' => true)) . " WHERE is_primary = '1' AND `contact_id` = {$this->contact->id}";
                     } else {
                         $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_phone", $fields, array('escape' => true));
                     }
                     $objDatabase->Execute($query);
                 }
             }
             \Cx\Core\Setting\Controller\Setting::init($prevSection, $prevGroup, $prevEngine);
         }
     }
 }
Example #23
0
 /**
  * Save the object in database and return if it's saved
  * @return boolean
  */
 public function save($widthUpdate = true)
 {
     // stop if nothing changed
     if (empty($this->changes)) {
         return false;
     }
     // get class name
     $class = get_class($this);
     // object key
     $key = $class::key;
     // prepare update query if already in database
     if ($this->{$key} && $widthUpdate) {
         $query = SQL::update($this->changes, $class::table, $key . '=:' . $key);
         $values = SQL::buildIns($this, $this->changes);
         // prepare insert query
     } else {
         $query = SQL::insert($class::columns, $class::table);
         $values = SQL::buildIns($this, $class::columns);
     }
     // add object key to values
     $values[':' . $key] = $this->{$key};
     // run statement
     $statement = new Database($query, $values);
     // get back key if it's a new object
     if (!$this->{$key}) {
         $this->{$key} = $statement->lastid();
     }
     return true;
 }