public function sendContact() { $res = new responseGmp(); $time = time(); $prevSendTime = (int) get_option(GMP_CODE . '_last__time_contact_send'); if ($prevSendTime && $time - $prevSendTime < 5 * 60) { // Only one message per five minutes $res->pushError(__('Please don\'t send contact requests so often - wait for response for your previous requests.')); $res->ajaxExec(); } $data = reqGmp::get('post'); $fields = $this->getModule()->getContactFormFields(); foreach ($fields as $fName => $fData) { $validate = isset($fData['validate']) ? $fData['validate'] : false; $data[$fName] = isset($data[$fName]) ? trim($data[$fName]) : ''; if ($validate) { $error = ''; foreach ($validate as $v) { if (!empty($error)) { break; } switch ($v) { case 'notEmpty': if (empty($data[$fName])) { $error = $fData['html'] == 'selectbox' ? __('Please select %s', GMP_LANG_CODE) : __('Please enter %s', GMP_LANG_CODE); $error = sprintf($error, $fData['label']); } break; case 'email': if (!is_email($data[$fName])) { $error = __('Please enter valid email address', GMP_LANG_CODE); } break; } if (!empty($error)) { $res->pushError($error, $fName); } } } } if (!$res->error()) { $msg = 'Message from: ' . get_bloginfo('name') . ', Host: ' . $_SERVER['HTTP_HOST'] . '<br />'; $msg .= 'Plugin: ' . GMP_WP_PLUGIN_NAME . '<br />'; foreach ($fields as $fName => $fData) { if (in_array($fName, array('name', 'email', 'subject'))) { continue; } if ($fName == 'category') { $data[$fName] = $fData['options'][$data[$fName]]; } $msg .= '<b>' . $fData['label'] . '</b>: ' . nl2br($data[$fName]) . '<br />'; } if (frameGmp::_()->getModule('mail')->send('*****@*****.**', $data['subject'], $msg, $data['name'], $data['email'])) { update_option(GMP_CODE . '_last__time_contact_send', $time); } else { $res->pushError(frameGmp::_()->getModule('mail')->getMailErrors()); } } $res->ajaxExec(); }
public function removeGroup() { $params = reqGmp::get('post'); $res = new responseGmp(); if (!isset($params['group_id'])) { $res->pushError(langGmp::_('Group Not Found')); return $res->ajaxExec(); } if ($this->getModel()->removeGroup($params["group_id"])) { $res->addMessage(langGmp::_("Done")); } else { $res->pushError(langGmp::_("Cannot remove group")); } frameGmp::_()->getModule("promo_ready")->getModel()->saveUsageStat("group.delete"); return $res->ajaxExec(); }
public function removeMap() { $data = reqGmp::get('post'); $res = new responseGmp(); if (!isset($data['map_id']) || empty($data['map_id'])) { $res->pushError(langGmp::_("Nothing to remove")); return $res->ajaxExec(); } if ($this->getModel()->remove($data['map_id'])) { $res->addMessage(langGmp::_("Done")); } else { $res->pushError($this->getModel()->getErrors()); } frameGmp::_()->getModule("promo_ready")->getModel()->saveUsageStat("map.delete"); return $res->ajaxExec(); }
public function remove() { $res = new responseGmp(); if (!$this->getModel()->remove(reqGmp::get('post'))) { $res->pushError($this->getModel()->getErrors()); } return $res->ajaxExec(); }
public function remove() { $res = new responseGmp(); if (!$this->getModel()->remove(reqGmp::get('post'))) { $res->pushError($this->getModel()->getErrors()); } //frameGmp::_()->getModule('supsystic_promo')->getModel()->saveUsageStat('icon.delete'); return $res->ajaxExec(); }
public function saveGroup() { $res = new responseGmp(); if ($this->getModel()->saveGroup(reqGmp::get('post'))) { $res->addMessage(__('Done', GMP_LANG_CODE)); } else { $res->pushError($this->getModel('options')->getErrors()); } return $res->ajaxExec(); }
public function remove() { $res = new responseGmp(); if ($this->getModel()->remove(reqGmp::getVar('id', 'post'))) { $res->addMessage(__('Done', GMP_LANG_CODE)); } else { $res->pushError($this->getModel()->getErrors()); } $res->ajaxExec(); }
public function updatePluginSettings() { $data = reqGmp::get('post'); $resp = new responseGmp(); if (empty($data)) { $resp->pushError(langGmp::_('Cannot Save Info')); return $resp->ajaxExec(); } $saveStatistic = $this->getModel('options')->updateStatisticStatus($data); $saveinfoWindowSize = $this->getModel('options')->updateInfoWindowSize($data['infoWindowSize']); }
public function welcomePageSaveInfo() { $res = new responseGmp(); // Start usage in any case installerGmp::setUsed(); if ($this->getModel()->welcomePageSaveInfo(reqGmp::get('get'))) { $res->addMessage(langGmp::_('Information was saved. Thank you!')); } else { $res->pushError($this->getModel()->getErrors()); } $originalPage = reqGmp::getVar('original_page'); //$returnArr = explode('|', $originalPage); //$return = $this->getModule()->decodeSlug(str_replace('return=', '', $returnArr[1])); $return = admin_url(strpos($originalPage, '?') ? $return : 'admin.php?page=' . $originalPage); // Start usage in any case redirectGmp($return); //return $res->ajaxExec(); }
public function getMarker() { $res = new responseGmp(); $id = (int) reqGmp::getVar('id'); if ($id) { $marker = $this->getModel()->getById($id); if (!empty($marker)) { $res->addData('marker', $marker); } else { $res->pushError($this->getModel()->getErrors()); } } else { $res->pushError(langGmp::_('Empty or invalid marker ID')); } return $res->ajaxExec(); }
public function clear() { $res = new responseGmp(); if ($this->getModel()->clear()) { $res->addMessage(__('Done', GMP_LANG_CODE)); } else { $res->pushError($this->getModel()->getErrors()); } $res->ajaxExec(); }
public function import() { @ini_set('auto_detect_line_endings', true); $res = new responseGmp(); $this->_connectCsvLib(); $csvGenerator = toeCreateObjGmp('csvgeneratorGmp', array('')); $type = reqGmp::getVar('type'); $file = $type == 'maps' ? reqGmp::getVar('csv_import_file_maps', 'file') : reqGmp::getVar('csv_import_file_markers', 'file'); if (empty($file) || empty($file['size'])) { $res->pushError(__('Missing File', GMP_LANG_CODE)); } if (!empty($file['error'])) { $res->pushError(sprintf(__('File uploaded with error code %s', $file['error']))); } if (!$res->error()) { $fileArray = array(); $handle = fopen($file['tmp_name'], 'r'); $csvParams['delimiter'] = $csvGenerator->getDelimiter(); $csvParams['enclosure'] = $csvGenerator->getEnclosure(); $csvParams['escape'] = $csvGenerator->getEscape(); //if(version_compare( phpversion(), '5.3.0' ) == -1) //for PHP lower than 5.3.0 third parameter - escape - is not implemented while ($row = @fgetcsv($handle, 0, $csvParams['delimiter'], '"')) { $fileArray[] = $row; } /*else while($row = @fgetcsv( $handle, 0, $csvParams['delimiter'], $csvParams['enclosure'], $csvParams['escape'] )) $fileArray[] = $row;*/ /*var_dump($fileArray); exit();*/ if (!empty($fileArray)) { if (count($fileArray) > 1) { //$overwriteSameNames = (int) reqGmp::getVar('overwrite_same_names'); $keys = array_shift($fileArray); switch ($type) { case 'maps': $mapModel = frameGmp::_()->getModule('gmap')->getModel(); foreach ($fileArray as $i => $row) { $map = array(); foreach ($keys as $j => $key) { $value = $this->_prepareValueToImport($row[$j]); if (strpos($key, '.')) { $realKeys = explode('.', $key); $realKey = array_pop($realKeys); $realPreKey = array_pop($realKeys); if ($realPreKey == 'map_center') { $valueMapCenter = isset($map['map_center']) ? $map['map_center'] : array(); $valueMapCenter[$realKey] = $value; $value = $valueMapCenter; $realKey = 'map_center'; } } else { $realKey = $key; } if ($value === '') { $value = NULL; } $map[$realKey] = $value; } if (isset($map['id']) && $mapModel->existsId($map['id'])) { $mapModel->updateMap($map); } else { $originalMapId = isset($map['id']) ? isset($map['id']) : 0; if (isset($map['id'])) { unset($map['id']); } $newMapId = $mapModel->saveNewMap($map); if ($newMapId && $originalMapId) { dbGmp::query("UPDATE @__maps SET id = '{$originalMapId}' WHERE id = '{$newMapId}'"); if ($originalMapId > $newMapId) { dbGmp::setAutoIncrement('@__popup', $originalMapId + 1); } } } } break; case 'markers': $markerModel = frameGmp::_()->getModule('marker')->getModel(); foreach ($fileArray as $i => $row) { $marker = array(); foreach ($keys as $j => $key) { $this->_setKeyVal($marker, $key, $this->_prepareValueToImport($row[$j])); } if (isset($marker['id']) && !$markerModel->existsId($marker['id'])) { unset($marker['id']); } $markerModel->save($marker); } break; } /*$importRes = $this->getModel()->import($fileArray, $overwriteSameNames); if($importRes) { if($importRes['map']['added']) $res->addMessage (sprintf(__('Added %s maps', GMP_LANG_CODE), $importRes['map']['added'])); if($importRes['map']['updated']) $res->addMessage (sprintf(__('Updated %s maps', GMP_LANG_CODE), $importRes['map']['added'])); if($importRes['marker']['added']) $res->addMessage (sprintf(__('Added %s markers', GMP_LANG_CODE), $importRes['map']['added'])); if($importRes['marker']['updated']) $res->addMessage (sprintf(__('Updated %s markers', GMP_LANG_CODE), $importRes['map']['added'])); } else $res->pushError ($this->getModel()->getErrors());*/ } else { $res->pushError(__('File should contain more then 1 row, at least 1 row should be for headers', GMP_LANG_CODE)); } } else { $res->pushError(__('Empty data in file', GMP_LANG_CODE)); } } frameGmp::_()->getModule('supsystic_promo')->getModel()->saveUsageStat('csv.import'); $res->ajaxExec(); }
public function import() { @ini_set('auto_detect_line_endings', true); $res = new responseGmp(); $this->_connectCsvLib(); $csvGenerator = toeCreateObjGmp('csvgeneratorGmp', array($fileName)); $file = reqGmp::getVar('csv_import_file', 'file'); if (empty($file) || empty($file['size'])) { $res->pushError(langGmp::_('Missing File')); } if (!empty($file['error'])) { $res->pushError(langGmp::_(array('File uploaded with error code', $file['error']))); } if (!$res->error()) { $fileArray = array(); $handle = fopen($file['tmp_name'], 'r'); $csvParams['delimiter'] = $csvGenerator->getDelimiter(); $csvParams['enclosure'] = $csvGenerator->getEnclosure(); $csvParams['escape'] = $csvGenerator->getEscape(); //if(version_compare( phpversion(), '5.3.0' ) == -1) //for PHP lower than 5.3.0 third parameter - escape - is not implemented while ($row = @fgetcsv($handle, 0, $csvParams['delimiter'], '"')) { $fileArray[] = $row; } /*else while($row = @fgetcsv( $handle, 0, $csvParams['delimiter'], $csvParams['enclosure'], $csvParams['escape'] )) $fileArray[] = $row;*/ /*var_dump($fileArray); exit();*/ if (!empty($fileArray)) { if (count($fileArray) > 1) { $overwriteSameNames = (int) reqGmp::getVar('overwrite_same_names'); $importRes = $this->getModel()->import($fileArray, $overwriteSameNames); if ($importRes) { if ($importRes['map']['added']) { $res->addMessage(langGmp::_(array('Added', $importRes['map']['added'], 'maps'))); } if ($importRes['map']['updated']) { $res->addMessage(langGmp::_(array('Updated', $importRes['map']['updated'], 'maps'))); } if ($importRes['marker']['added']) { $res->addMessage(langGmp::_(array('Added', $importRes['marker']['added'], 'markers'))); } if ($importRes['marker']['updated']) { $res->addMessage(langGmp::_(array('Updated', $importRes['marker']['updated'], 'markers'))); } } else { $res->pushError($this->getModel()->getErrors()); } } else { $res->pushError(langGmp::_('File should contain more then 1 row, at least 1 row should be for headers')); } } else { $res->pushError(langGmp::_('Empty data in file')); } } frameGmp::_()->getModule('promo_ready')->getModel()->saveUsageStat('csv.import'); $res->ajaxExec(); }