示例#1
0
	/**
	 * Install module
	 * @return Boolean Returns TRUE if successful, FALSE otherwise
	 * @throws E_USER_ERROR Your database type is not in our implementation list
	 * @throws E_USER_NOTICE Cannot execute query
	 */
	function install()
	{
		switch (SENDSTUDIO_DATABASE_TYPE) {
			case 'mysql':
				require(dirname(__FILE__) . '/_install/mysql.php');
			break;

			case 'pgsql':
				require(dirname(__FILE__) . '/_install/pgsql.php');
			break;

			default:
				trigger_error('Your database type is not in our implementation list', E_USER_ERROR);
				return false;
			break;
		}

		$db = IEM::getDatabase();

		foreach ($queries as $name => $query) {
			$status = $db->Query($query);
			if ($status == false) {
				trigger_error('module_Tracker_Admin::install -- Cannot execute query "' . $name . '" to install. Error returned: ' . $db->Error(), E_USER_NOTICE);
				return false;
			}
		}

		return true;
	}
	/**
	 * RunUpgrade
	 * Run current upgrade
	 *
	 * @return Boolean Returns TRUE if successful, FALSE otherwise
	 */
	function RunUpgrade()
	{
		// Upgrading from a very old installation. Ignore this upgrade since it is not a crucial upgrade.
		if (!IEM::getDatabase()) {
			return true;
		}

		try {
			// We want to install & enable this addon, but we may need to configure it first.
			require_once IEM_ADDONS_PATH . '/systemlog/systemlog.php';
			$systemlog = new Addons_systemlog();
			$systemlog->Install();
			$systemlog->Disable(); // It may have already been installed/enabled
			$settings = Addons_systemlog::GetSettings();
			if (empty($settings)) {
				$settings = array('logsize' => 1000);
			}
			Addons_systemlog::SetSettings($settings); // This will mark it as 'configured' too.
			$systemlog->Enable();
		} catch (Exception $e) {
			return true;
		}

		return true;
	}
 /**
  * CONSTRUCTOR
  * Initialises the required settings.
  */
 public function __construct()
 {
     $this->_settings = array('DATABASE_TYPE' => null, 'LICENSEKEY' => null, 'APPLICATION_URL' => null, 'EMAIL_ADDRESS' => null, 'DATABASE_USER' => null, 'DATABASE_PASS' => null, 'DATABASE_HOST' => null, 'DATABASE_NAME' => null, 'TABLEPREFIX' => null);
     if (is_callable(array('IEM', 'getDatabase'))) {
         $this->_api = IEM::getDatabase();
     }
 }
示例#4
0
 /**
  * __construct
  * Constructor for block init
  *
  * @param int $blockId              The ID of block
  * @param string $name              The Name of block
  * @param string $rules             The Rules Set of block
  * @param int $activated            The Default Status of block
  * @param int $sortorder            The Sort order of block
  * @param int $tagId                The Tag Id of block
  *
  * @return void                     This create a new instance of the block object
  *
  */
 public function __construct($blockId, $name, $rules, $activated, $sortorder, $tagId)
 {
     $this->setBlockId($blockId);
     $this->setName($name);
     $this->setRules($rules);
     $this->setActivated($activated);
     $this->setSortOrder($sortorder);
     $this->setTagId($tagId);
     $this->db = IEM::getDatabase();
 }
	/**
	* Constructor
	* Doesn't do anything.
	*
	* @return Void Doesn't return anything.
	*/
	public function __construct()
	{
	    // if iem is already installed, then we redirect to the home page
	    if (IEM::isInstalled()) {
	        header('Locatin: index.php');
	        
	        exit;
	    }
	    
		$this->_api = new IEM_Installer();
	}
示例#6
0
文件: init.php 项目: hungnv0789/vhtm
/**
 * Shutdown function
 * Function that will be called when the script finishes execution.
 *
 * @return Void Returns nothing
 */
function __iem_shutdown_function()
{
    $tempEvent = new EventData_IEM_SYSTEM_SHUTDOWN_BEFORE();
    $tempEvent->trigger();
    unset($tempEvent);
    if (!IEM::configSave()) {
        trigger_error('Cannot save configuration variable to file', E_USER_WARNING);
    }
    $tempEvent = new EventData_IEM_SYSTEM_SHUTDOWN_AFTER();
    $tempEvent->trigger();
    unset($tempEvent);
}
示例#7
0
	/**
	 * RunUpgrde
	 * Run current upgrade
	 * @return Boolean Returns TRUE if successful, FALSE otherwise
	 */
	function RunUpgrade()
	{
		$new_version = '20081215';

		$errors = IEM::sessionGet('DatabaseUpgradesFailed');

		if (empty($errors)) {
			$query = 'UPDATE ' . SENDSTUDIO_TABLEPREFIX . 'settings SET database_version=' . $new_version;
			$result = $this->Db->Query($query);
			return $result;
		}

		return false;
	}
示例#8
0
 /**
  * __construct
  * Constructor for tag init
  *
  * @param int $tagId                The dynamic content tag id
  * @param string $name              The name of dynamic content tag
  * @param int $createDate           The creation date of dynamic content tag
  * @param int $ownerId			    The owner id of dynamic content tag
  * @param array $blocks             A list of blocks objects of the dynamic content tag
  * @param array $lists              A list of contact list ids of the dynamic content tag
  *
  * @return void                     This create a new instance of the dynamic content tag object
  *
  */
 public function __construct($tagId, $name = '', $createDate = 0, $ownerId = 0, $blocks = array(), $lists = array())
 {
     $this->db = IEM::getDatabase();
     if (func_num_args() == 1) {
         $this->load($tagId);
     } else {
         $this->setTagId($tagId);
         $this->setName($name);
         $this->setCreatedDate($createDate);
         $this->setBlocks($blocks);
         $this->setLists($lists);
         $this->setOwnerId($ownerId);
     }
 }
示例#9
0
 /**
  * Disguise action
  *
  * Administrator is able to disguise (and login) as other users.
  * This method will facilitate this functionalities.
  *
  * TODO better PHPDOC
  */
 public function page_disguise()
 {
     // newUserID variable need to be passed in as a POST variable
     $reqUserID = IEM::requestGetPOST('newUserID', 0, 'intval');
     if (empty($reqUserID)) {
         IEM::redirectTo('index');
         return false;
     }
     // Attempt to login user with different ID
     if (!IEM::userLogin($reqUserID, false)) {
         IEM::redirectTo('index');
         return false;
     }
     IEM::redirectTo('index');
     return true;
 }
示例#10
0
function ssk2sdf3twgsdfsfezm2()
{
	$LicenseKey = SENDSTUDIO_LICENSEKEY; $lice = ssds02afk31aadnnb($LicenseKey);
	if (!$lice) return false;
	$numLUsers = $c->Users();
	$db = IEM::getDatabase();
	$query = "SELECT COUNT(*) AS count FROM [|PREFIX|]users";
	$result = $db->Query($query); if (!$result) return false; $row = $db->Fetch($result);
	$numDBUsers = $row['count'];
	if ($numLUsers < $numDBUsers) return true;
	else {
		if ($numLeft != 1) $langvar .= '_Multiple';
		if (!defined('CurrentUserReport')) require_once(dirname(__FILE__) . '/../language/language.php');
		$msg = sprintf(GetLang($langvar), $current_users, $current_admins, $numLeft);
		return $msg;
	}
}
示例#11
0
	/**
	* Process
	* Logs you out and redirects you back to the login page.
	*
	* @see Login::Process
	*
	* @return Void Doesn't return anything. Unsets session variables, removes the "remember me" cookie if it's set and redirects you back to the login page.
	*/
	function Process()
	{
		$sessionuser = IEM::getCurrentUser();
		$sessionuser->SaveSettings();
		unset($sessionuser);
		
		IEM::userLogout();
		
		IEM::requestRemoveCookie('IEM_CookieLogin');
		IEM::requestRemoveCookie('IEM_LoginPreference');

		$url = SENDSTUDIO_APPLICATION_URL;
		if (substr($url, -1, 1) != '/') {
			$url .= '/';
		}
		$url .= 'admin/index.php';

		header("Location: {$url}");
		exit();
	}
示例#12
0
	/**
	* ViewSubscriber
	* Prints the 'view subscriber' page and all appropriate options including custom fields.
	*
	* @param Int $listid The list the subscriber is on. This is checked to make sure the user has 'manage' access to the list before anything else.
	* @param Int $subscriberid The subscriberid to view.
	* @param Int $segmentid The ID of the segment that the subscriber is going to be fetched from
	* @param String $msgtype The heading to show when viewing a subscriber. This can be either error or success. Used with $msg to display something.
	* @param String $msg The message to display in the heading. If this is not present, no message is displayed.
	*
	* @see GetApi
	* @see Subscribers_API::GetCustomFieldSettings
	* @see Lists_API::GetCustomFields
	* @see Lists_API::Load
	* @see Lists_API::GetListFormat
	*
	* @return Void Doesn't return anything. Prints out the view form and that's it.
	*/
	function ViewSubscriber($listid = 0, $subscriberid = 0, $segmentid = 0, $msgtype = 'Error', $msg = false)
	{
		$user = GetUser();
		$access = $user->HasAccess('Subscribers', 'Manage');
		if (!$access) {
			$this->DenyAccess();
			return;
		}

		$this->SetupGoogleCalendar();

		$search_info = IEM::sessionGet('Search_Subscribers');

		$GLOBALS['list'] = $listid;

		if ($msg && $msgtype) {
			switch (strtolower($msgtype)) {
				case 'success':
					$GLOBALS['Success'] = $msg;
					$GLOBALS['Message'] = $this->ParseTemplate('SuccessMsg', true, false);
				break;
				default:
					$GLOBALS['Error'] = $msg;
					$GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
			}
		}

		$SubscriberApi = $this->GetApi('Subscribers');
		$subscriberinfo = false;

		/**
		 * Get Subscriber record from the database
		 */
			$adminAccess = false;

			// If this user is an admin/list admin/list admintype == a then give permission
			if ($user->Admin() || $user->ListAdminType() == 'a' || $user->ListAdmin()) {
				$adminAccess = true;
			}

			// Get subscribers from list
			if ($segmentid == 0) {
				if (!$adminAccess && !$SubscriberApi->CheckPermission($user->userid, $subscriberid)) {
					$this->DenyAccess();
					return;
				}

				$subscriberinfo = $SubscriberApi->LoadSubscriberList($subscriberid, $listid);


			// Get subscribers from segment
			} else {
				if (!$adminAccess) {
					$segmentapi = $this->GetApi('Segment', true);
					$segmentapi->Load($segmentid);

					if ($segmentapi->ownerid != $user->userid && !$user->HasAccess('Segments', 'View', $segmentid)) {
						$this->DenyAccess();
						return;
					}
				}

				$subscriberinfo = $SubscriberApi->LoadSubscriberSegment($subscriberid, $segmentid);
			}
		/**
		 * -----
		 */

		// hmm, the subscriber doesn't exist or can't be loaded? show an error.
		if (empty($subscriberinfo)) {
			$GLOBALS['ErrorMessage'] = GetLang('SubscriberDoesntExist_View');
			$this->DenyAccess();
			return;
		}

		// Log this to "User Activity Log"
		$logURL = SENDSTUDIO_APPLICATION_URL . '/admin/index.php?Page=Subscribers&Action=Edit&List=' . $_GET['List'] . '&id=' . $_GET['id'];
		IEM::logUserActivity($logURL, 'images/contacts_view.gif', $subscriberinfo['emailaddress']);

		$list_api = $this->GetApi('Lists');
		$list_api->Load($listid);

		$GLOBALS['emailaddress'] = $subscriberinfo['emailaddress'];
		$GLOBALS['subscriberid'] = $subscriberid;

		if ($subscriberinfo['requestdate'] == 0) {
			$GLOBALS['requestdate'] = GetLang('Unknown');
		} else {
			$GLOBALS['requestdate'] = $this->PrintTime($subscriberinfo['requestdate']);
		}

		$GLOBALS['requestip'] = ($subscriberinfo['requestip'] == '') ? GetLang('Unknown') : $subscriberinfo['requestip'];

		if ($subscriberinfo['confirmdate'] == 0) {
			$GLOBALS['confirmdate'] = GetLang('Unknown');
		} else {
			$GLOBALS['confirmdate'] = $this->PrintTime($subscriberinfo['confirmdate']);
		}

		$GLOBALS['confirmip'] = ($subscriberinfo['confirmip'] == '') ? GetLang('Unknown') : $subscriberinfo['confirmip'];

		if ($subscriberinfo['confirmed'] == 1) {
			$confirmed = 'Confirmed';
		} elseif ($subscriberinfo['confirmed'] == 0) {
			$confirmed = 'Unconfirmed';
		}

		$GLOBALS['ConfirmedList'] = GetLang($confirmed);

		$GLOBALS['ShowUnsubscribeInfo'] = 'none';

		$subscriber_status = 'a';
		if ($subscriberinfo['unsubscribed'] > 0) {
			$subscriber_status = 'u';
			$GLOBALS['unsubscribetime'] = $this->PrintTime($subscriberinfo['unsubscribed']);
			$GLOBALS['unsubscribeip'] = ($subscriberinfo['unsubscribeip'] == '') ? GetLang('Unknown') : $subscriberinfo['unsubscribeip'];
			$GLOBALS['ShowUnsubscribeInfo'] = '';
		}

		if ($subscriberinfo['bounced'] > 0) {
			$subscriber_status = 'b';
		}

		switch ($subscriber_status) {
			case 'a':
				$status = 'Active';
			break;

			case 'u':
				$status = 'Unsubscribed';
			break;

			case 'b':
				$status = 'Bounced';
			break;

			default:
		}

		// this is used both by the 'edit' and 'delete' buttons.
		$GLOBALS['subscriberid'] = $subscriberid;
		if ($segmentid != 0) {
			$GLOBALS['SegmentID'] = $segmentid;
			$GLOBALS['ExtraParameter'] = '&SegmentID=' . $segmentid;
		} else {
			$GLOBALS['SegmentID'] = 0;
			$GLOBALS['ExtraParameter'] = '';
		}

		$GLOBALS['EditButton'] = '';
		if ($user->HasAccess('Subscribers', 'Edit')) {
			$GLOBALS['EditButton'] = $this->ParseTemplate('Subscribers_View_Button_Edit', true, false);
		}

		$GLOBALS['DeleteButton'] = '';
		if ($user->HasAccess('Subscribers', 'Delete')) {
			$GLOBALS['DeleteButton'] = $this->ParseTemplate('Subscribers_View_Button_Delete', true, false);
		}

		$GLOBALS['StatusList'] = GetLang($status);

		$listformat = $list_api->GetListFormat();

		if ($subscriberinfo['format'] == 'h') {
			$format = GetLang('Format_HTML');
		} elseif ($subscriberinfo['format'] == 't') {
			$format = GetLang('Format_Text');
		}

		$GLOBALS['FormatList'] = $format;

		$customfields = $list_api->GetCustomFields($listid);

		$customfield_display = array();
		$customfieldinfo = '';

		if (!empty($customfields)) {
			$customfields_api = $this->GetApi('CustomFields');

			$customfieldinfo .= $this->ParseTemplate('Subscribers_Edit_Step2_CustomFields', true, false);
			foreach ($customfields as $pos => $customfield_info) {
				$GLOBALS['FieldID'] = $customfield_info['fieldid'];
				if ($customfield_info['required']) {
					$GLOBALS['Required'] = $this->ParseTemplate('Required', true, false);
				} else {
					$GLOBALS['Required'] = $this->ParseTemplate('Not_Required', true, false);
				}

				$subscriber_settings = $SubscriberApi->GetCustomFieldSettings($customfield_info['fieldid']);

				$customfields_api->fieldid = $customfield_info['fieldid'];
				$customfields_api->fieldtype = $customfield_info['fieldtype'];

				$subfield = $customfields_api->LoadSubField();

				$GLOBALS['FieldName'] = htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
				$GLOBALS['FieldValue'] = htmlspecialchars($subfield->GetRealValue($subscriber_settings), ENT_QUOTES, SENDSTUDIO_CHARSET);

				switch ($customfield_info['fieldtype']) {
					case 'textarea':
						$template_name = 'Subscribers_View_CustomField_TextArea';
					break;
					case 'date':
						$fieldsettings = unserialize($customfield_info['fieldsettings']);
						$GLOBALS['DateJSON'] = '';
						$GLOBALS['GoogleCalendarButton'] = '';
						if (strlen($GLOBALS['FieldValue'])) {
							$date = explode('/',$GLOBALS['FieldValue']);
							$datejson = array_combine(array_slice($fieldsettings['Key'],0,3),$date);

							$GLOBALS['DateJSON'] = GetJSON($datejson);

							if (strlen($user->googlecalendarusername) && strlen($user->googlecalendarpassword)) {
								$GLOBALS['GoogleCalendarButton'] =  $this->ParseTemplate('google_calendar_button',true);
							} else {
								$GLOBALS['GoogleCalendarButton'] =  $this->ParseTemplate('google_calendar_button_disabled',true);
							}
						}

						$template_name = 'Subscribers_View_CustomField_Date';
					break;
					default:
						$template_name = 'Subscribers_View_CustomField';
				}

				$customfield_display[] = $this->ParseTemplate($template_name, true, false);
				unset($subfield);
			}

			$column1 = $column2 = array();
			if (count($customfield_display) > 9) {
				$customfieldinfo_template = 'Subscribers_customfieldinfo_twocolumns';
				$split = ceil(count($customfield_display) / 2);

				for ($i = 0; $i < $split; $i++) {
					$column1[] = $customfield_display[$i];
					if (isset($customfield_display[$i + $split])) {
						$column2[] = $customfield_display[$i + $split];
					} else {
						$column2[] = '<td>&nbsp;</td><td>&nbsp;</td>';
					}
				}

				$GLOBALS['CustomFieldInfo_1'] = '<tr>' . implode('</tr><tr>',$column1) . '</tr>';
				$GLOBALS['CustomFieldInfo_2'] = '<tr>' . implode('</tr><tr>',$column2) . '</tr>';
			} else {
				$customfieldinfo_template = 'Subscribers_customfieldinfo_onecolumn';
				$GLOBALS['CustomFieldInfo_1'] = '';
				foreach ($customfield_display as $field) {
					$GLOBALS['CustomFieldInfo_1'] .= '<tr>' . $field . '</tr>';
				}
			}
			$GLOBALS['CustomFieldInfo'] = $customfieldinfo . $this->ParseTemplate($customfieldinfo_template,true);
		}

		$GLOBALS['listid'] = $listid;

		$actions = $user->GetEventActivityType();
		$GLOBALS['Actions'] = '';
		foreach ($actions as $action) {
			$GLOBALS['Actions'] .= '<option value="' . htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . '">'. htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . "</option>";
		}

		$GLOBALS['EventTypesJSON'] = GetJSON($actions);
		$GLOBALS['EventAddForm'] = $this->ParseTemplate('Subscriber_Event_Add',true,false);

		$GLOBALS['DatePickerJavascript'] = $this->ParseTemplate('ui.datepicker.custom_iem',true,false);

		if (IEM::sessionGet('gcal_allday')) {
			$GLOBALS['GoogleCalendarAllDay'] = 'true';
		} else {
			$GLOBALS['GoogleCalendarAllDay'] = 'false';
		}

		$GLOBALS['SubscriberEvents_Intro'] = GetLang('SubscriberEvents_Intro');
		if ($user->HasAccess('Subscribers','EventSave')) {
			$GLOBALS['SubscriberEvents_Intro'] .= GetLang('SubscriberEvents_Intro_AddEvent');
		}

		$this->ParseTemplate('Subscribers_View_Step2');
	}
	/**
	* EditAutoresponderStep4
	* Loads up step 4 of editing an autoresponder which is editing the actual content.
	* If you pass in an autoresponderid, it will load it up and set the appropriate language variables.
	*
	* @param Int $autoresponderid AutoresponderID to edit.
	*
	* @return Void Prints out step 4, doesn't return anything.
	*/
	function EditAutoresponderStep4($autoresponderid=0)
	{

		$autoapi = $this->GetApi();
		$autorespondercontents = array('text' => '', 'html' => '');

		$this->DisplayCronWarning();

		$user = GetUser();
		$GLOBALS['FromPreviewEmail'] = $user->Get('emailaddress');

		//$GLOBALS['DisplayAttachmentsHeading'] = 'none';
		$tpl = GetTemplateSystem();
		if ($autoresponderid > 0) {
			$GLOBALS['SaveAction'] = 'Edit&SubAction=Save&id=' . $autoresponderid;
			$GLOBALS['Heading'] = GetLang('EditAutoresponder');
			$GLOBALS['Intro'] = GetLang('EditAutoresponderIntro_Step4');
			$GLOBALS['Action'] = 'Edit&SubAction=Complete&id=' . $autoresponderid;
			$GLOBALS['CancelButton'] = GetLang('EditAutoresponderCancelButton');

			$autoapi->Load($autoresponderid);
			$autorespondercontents['text'] = $autoapi->GetBody('text');
			$autorespondercontents['html'] = $autoapi->GetBody('html');

			$GLOBALS['Subject'] = htmlspecialchars($autoapi->subject, ENT_QUOTES, SENDSTUDIO_CHARSET);

		} else {

			$GLOBALS['SaveAction'] = 'Create&SubAction=Save&id=' . $autoresponderid;
			$GLOBALS['Heading'] = GetLang('CreateAutoresponder');
			$GLOBALS['Intro'] = GetLang('CreateAutoresponderIntro_Step4');
			$GLOBALS['Action'] = 'Create&SubAction=Complete';
			$GLOBALS['CancelButton'] = GetLang('CreateAutoresponderCancelButton');
		}

		if (SENDSTUDIO_ALLOW_ATTACHMENTS) {
				$attachmentsarea = strtolower(get_class($this));
				$attachments_list = $this->GetAttachments($attachmentsarea, $autoresponderid);
				$GLOBALS['AttachmentsList'] = $attachments_list;
				$tpl->Assign('ShowAttach', true);
		} else {
			$GLOBALS['DisplayAttachments'] = 'none';
			$user = IEM::getCurrentUser();
			if($user) {
				if ($user->isAdmin()) {
					$GLOBALS['AttachmentsMsg'] = GetLang('NoAttachment_Admin');
				} else {
					$GLOBALS['AttachmentsMsg'] = GetLang('NoAttachment_User');
				}
			}
			$tpl->Assign('ShowAttach', false);
		}

		$GLOBALS['PreviewID'] = $autoresponderid;

		// we don't really need to get/set the stuff here.. we could use references.
		// if we do though, it segfaults! so we get and then set the contents.
		$session_autoresponder = IEM::sessionGet('Autoresponders');

		$GLOBALS['List'] = $session_autoresponder['list'];

		if (isset($session_autoresponder['TemplateID'])) {
			$templateApi = $this->GetApi('Templates');
			if (is_numeric($session_autoresponder['TemplateID'])) {
				$templateApi->Load($session_autoresponder['TemplateID']);
				$autorespondercontents['text'] = $templateApi->textbody;
				$autorespondercontents['html'] = $templateApi->htmlbody;
			} else {
				$autorespondercontents['html'] = $templateApi->ReadServerTemplate($session_autoresponder['TemplateID']);
			}
			unset($session_autoresponder['TemplateID']);
		}

		$session_autoresponder['id'] = (int)$autoresponderid;

		$session_autoresponder['contents'] = $autorespondercontents;

		// we use the lowercase variable when we save, but the editor expects the uppercased version.
		$session_autoresponder['Format'] = $session_autoresponder['format'];

		IEM::sessionSet('Autoresponders', $session_autoresponder);
		$editor = $this->FetchEditor();
		$GLOBALS['Editor'] = $editor;

		unset($session_autoresponder['Format']);
		$GLOBALS['MaxFileSize'] = SENDSTUDIO_ATTACHMENT_SIZE*1024;

		$user = GetUser();
		if ($user->Get('forcespamcheck')) {
			$GLOBALS['ForceSpamCheck'] = 1;
		}

		$tpl->ParseTemplate('Autoresponder_Form_Step4');
	}
示例#14
0
文件: users.php 项目: hungnv0789/vhtm
	/**
	* DeleteUsers
	* Deletes a list of users from the database via the api. Each user is checked to make sure you're not going to accidentally delete your own account and that you're not going to delete the 'last' something (whether it's the last active user, admin user or other).
	* If you aren't an admin user, you can't do anything at all.
	*
	* @param integer[] $users An array of userid's to delete
	* @param boolean $deleteData Whether or not to delete data owned by user along
	*
	* @see GetUser
	* @see User_API::UserAdmin
	* @see DenyAccess
	* @see CheckUserSystem
	* @see PrintManageUsers
	*
	* @return Void Doesn't return anything. Works out the relevant message about who was/wasn't deleted and prints that out. Returns control to PrintManageUsers.
	*/
	function DeleteUsers($users = array(), $deleteData = false)
	{
		$thisuser = GetUser();
		if (!$thisuser->UserAdmin()) {
			$this->DenyAccess();
			return;
		}

		if (!is_array($users)) {
			$users = array($users);
		}

		$not_deleted_list = array();
		$not_deleted = $deleted = 0;
		foreach ($users as $p => $userid) {
			if ($userid == $thisuser->Get('userid')) {
				$not_deleted++;
				$not_deleted_list[$userid] = array('username' => $thisuser->Get('username'), 'reason' => GetLang('User_CantDeleteOwn'));
				continue;
			}

			$error = $this->CheckUserSystem($userid);
			if (!$error) {
				$result = API_USERS::deleteRecordByID($userid, $deleteData);

				if ($result) {
					$deleted++;
				} else {
					$not_deleted++;
					$user = GetUser($userid);
					if ($user instanceof User_API) {
						$not_deleted_list[$userid] = array('username' => $user->Get('username'), 'reason' => '');
					} else {
						$not_deleted_list[$userid] = array('username' => $userid, 'reason' => '');
					}
				}
			} else {
				$not_deleted++;
				$user = GetUser($userid);
				if ($user instanceof User_API) {
					$not_deleted_list[$userid] = array('username' => $user->Get('username'), 'reason' => $error);
				} else {
					$not_deleted_list[$userid] = array('username' => $userid, 'reason' => $error);
				}
			}
		}


		if ($not_deleted > 0) {
			foreach ($not_deleted_list as $uid => $details) {
				FlashMessage(sprintf(GetLang('UserDeleteFail'), htmlspecialchars($details['username'], ENT_QUOTES, SENDSTUDIO_CHARSET), htmlspecialchars($details['reason'], ENT_QUOTES, SENDSTUDIO_CHARSET)), SS_FLASH_MSG_ERROR);
			}
		}

		if ($deleted > 0) {
			if ($deleted == 1) {
				FlashMessage(GetLang('UserDeleteSuccess_One'), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users'));
			} else {
				FlashMessage(sprintf(GetLang('UserDeleteSuccess_Many'), $this->FormatNumber($deleted)), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users'));
			}
		}

		IEM::redirectTo('Users');
	}
示例#15
0
 /**
  * Show_Send_Step_30
  * This shows a summary report of the split test campaign
  * after a user has paused the campaign
  * and they want to resume sending it
  *
  * It shows:
  * - which lists/segments it will be sent to
  * - the split test name
  * - which campaigns it will send
  *
  * and a "resume" button.
  *
  * If cron is enabled, then it will mark the job as "waiting" to send again in the database,
  * set a flash message and redirect the user back to the "manage split tests" page.
  *
  * @uses GetApi
  * @uses Splittest_API::Load
  * @uses Jobs_API::LoadJob
  * @uses CheckCronEnabled
  * @uses Splittest_Send_API::ResumeJob
  */
 public function Show_Send_Step_30()
 {
     $splitid = 0;
     if (isset($_GET['id'])) {
         $splitid = (int) $_GET['id'];
     }
     $api = $this->GetApi();
     $split_campaign_details = $api->Load($splitid);
     if (empty($split_campaign_details)) {
         FlashMessage(GetLang('Addon_splittest_Send_InvalidSplitTest'), SS_FLASH_MSG_ERROR, $this->admin_url);
         return;
     }
     $jobid = 0;
     if (isset($split_campaign_details['jobid'])) {
         $jobid = (int) $split_campaign_details['jobid'];
     }
     require_once SENDSTUDIO_API_DIRECTORY . '/jobs.php';
     $jobApi = new Jobs_API();
     $job = $jobApi->LoadJob($jobid);
     if (empty($job)) {
         FlashMessage(GetLang('Addon_splittest_Send_InvalidSplitTest'), SS_FLASH_MSG_ERROR, $this->admin_url);
         return;
     }
     /**
      * If we're sending via cron,
      * then mark the job as "waiting" to send again
      * and then show an appropriate message.
      */
     if (self::CheckCronEnabled()) {
         $send_api = $this->GetApi('SplitTest_Send');
         $resumed = $send_api->ResumeJob($jobid, $splitid);
         if ($resumed) {
             FlashMessage(GetLang('Addon_splittest_Send_Resumed_Success'), SS_FLASH_MSG_SUCCESS, $this->admin_url);
         } else {
             FlashMessage(GetLang('Addon_splittest_Send_Resumed_Failure'), SS_FLASH_MSG_ERROR, $this->admin_url);
         }
         return;
     }
     $sendingCampaigns = array();
     $send_details['newsletters'] = array();
     foreach ($split_campaign_details['splittest_campaigns'] as $campaignid => $campaignname) {
         $sendingCampaigns[$campaignid] = htmlspecialchars($campaignname, ENT_QUOTES, SENDSTUDIO_CHARSET);
         $send_details['newsletters'][] = $campaignid;
     }
     $send_list = array();
     switch ($job['jobdetails']['sendingto']['sendtype']) {
         case 'list':
             require_once SENDSTUDIO_API_DIRECTORY . '/lists.php';
             $list_api = new Lists_API();
             foreach ($job['jobdetails']['sendingto']['sendids'] as $listid) {
                 $list_api->Load($listid);
                 $send_list[] = htmlspecialchars($list_api->Get('name'), ENT_QUOTES, SENDSTUDIO_CHARSET);
             }
             $this->template_system->Assign('SendingToLists', true);
             break;
         case 'segment':
             require_once SENDSTUDIO_API_DIRECTORY . '/segment.php';
             $segment_api = new Segment_API();
             foreach ($job['jobdetails']['sendingto']['sendids'] as $segmentid) {
                 $segment_api->Load($segmentid);
                 $send_list[] = htmlspecialchars($segment_api->Get('segmentname'), ENT_QUOTES, SENDSTUDIO_CHARSET);
             }
             $this->template_system->Assign('SendingToSegments', true);
             break;
     }
     /**
      * Set everything in the session ready to go.
      */
     $job['jobdetails']['Job'] = $job['jobid'];
     IEM::sessionSet('SplitTestSendDetails', $job['jobdetails']);
     /**
      * Work out how many more emails there are to send.
      */
     $send_size = $job['jobdetails']['sendinfo']['sendsize_left'];
     if ($send_size == 1) {
         $send_size_msg = GetLang('Addon_splittest_Send_Step3_Size_One');
     } else {
         $send_size_msg = sprintf(GetLang('Addon_splittest_Send_Step3_Size_Many'), $this->PrintNumber($send_size));
     }
     $this->template_system->Assign('SendingToNumberOfContacts', $send_size_msg);
     $this->template_system->Assign('sendingCampaigns', $sendingCampaigns);
     $this->template_system->Assign('sendLists', $send_list);
     $this->template_system->Assign('AdminUrl', $this->admin_url, false);
     $this->template_system->ParseTemplate('send_step3');
 }
示例#16
0
 /**
  * GetSettings
  * Retrieves the saved settings from the database.
  *
  * @see Configure
  * @uses db
  *
  * @return Array The saved settings.
  */
 public static function GetSettings()
 {
     $db = IEM::getDatabase();
     if (!$db) {
         return array();
     }
     $id = str_replace('Addons_', '', __CLASS__);
     $settings = $db->FetchOne("SELECT settings FROM [|PREFIX|]addons WHERE addon_id='{$id}'");
     if (!$settings) {
         return array();
     }
     return unserialize($settings);
 }
	/**
	* DisplayChart
	* Sets the URL for chart data and sets the variables to display the chart
	*
	* @param String $chartname The variable name for the chart
	* @param String $chart_area The statistics area the chart is for
	* @param Int $statid The statid the chart is for
	* @param String $type The type of chart to display
	* @param Array $settings Settings for the chart
	*
	* @see InsertChartImage
	*
	* @return Void Returns nothing
	*/
	function DisplayChart($chartname='', $chart_area='', $statid=0, $type = 'pie', $settings = null)
	{
		$data_url = 'stats_chart.php?graph=' . urlencode(strtolower($chartname)) . '&Area='.urlencode(strtolower($chart_area)) . '&statid=' . (int)$statid . '&' . IEM::SESSION_NAME . '=' . IEM::sessionID();

		$this->InsertChartImage($chartname,$data_url);
	}
示例#18
0
/**
* GetUser
* If a userid is passed in, it will create a new user object and return the reference to it.
* If no userid is passed in, it will get the current user from the session.
*
* @param Int $userid If a userid is passed in, it will create a new user object and return it. If there is no userid it will get the current user from the session.
*
* @see User
*
* @return User_API The user object.
*
* @todo deprecate this in favour of IEM::getCurrentUser function
*/
function GetUser($userid = 0)
{
    if ($userid == 0) {
        $UserDetails = IEM::getCurrentUser();
        return $UserDetails;
    }
    if ($userid == -1) {
        $user = new User_API();
    } else {
        $user = new User_API($userid);
    }
    return $user;
}
示例#19
0
 /**
  * saveResponseAction
  * Save the actual save response action
  *
  * @return void
  *
  */
 public function Admin_Action_SaveResponse()
 {
     $surveyId = (int) IEM::requestGetPOST('formId');
     // check permission here
     $this->_checkSurveyAccess($surveyId);
     $responseId = IEM::requestGetPOST('responseId');
     $responseNumber = IEM::requestGetPOST('responseNumber');
     $postWidgets = IEM::requestGetPOST('widget');
     $errors = 0;
     if ($postWidgets || $_FILES) {
         // If there are files, take the values and place them in the $postWidgets array so they can
         // get validated and entered into the response values in the same manner. Uploads will be
         // handled separately.
         if (isset($_FILES['widget'])) {
             foreach ($_FILES['widget']['name'] as $widgetId => $widget) {
                 foreach ($widget as $fields) {
                     foreach ($fields as $fieldId => $field) {
                         if ($field['value']) {
                             $postWidgets[$widgetId]['field'][$fieldId]['value'] = 'file_' . $field['value'];
                         }
                     }
                 }
             }
         }
         $survey_api = $this->getApi();
         $survey_api->Load($surveyId);
         $widgets = $survey_api->getWidgets();
         $widgetErrors = array();
         foreach ($widgets as $widget) {
             if (!isset($widgetErrors[$widget['id']])) {
                 $widgetErrors[$widget['id']] = array();
             }
             // validate required fields
             if ($widget['is_required']) {
                 // the widget is assumed blank until one of it's fields is found not blank
                 $isBlank = true;
                 $isOther = false;
                 // make sure the required widget was even posted
                 if (isset($postWidgets[$widget['id']])) {
                     foreach ($postWidgets[$widget['id']]['field'] as $field) {
                         if (isset($field['value'])) {
                             // get the value of an "other" field if it is one, otherwise just grab
                             // the normal value
                             if ($field['value'] == '__other__') {
                                 $isOther = true;
                                 $value = $field['other'];
                             } else {
                                 $value = $field['value'];
                             }
                             // make sure the value isn't blank
                             if (!$this->_validateIsBlank($value)) {
                                 $isBlank = false;
                             }
                         }
                     }
                 }
                 // if the widget is blank, flag an error
                 if ($isBlank) {
                     if ($isOther) {
                         $error = GetLang('Addon_Surveys_ErrorRequiredOther');
                     } else {
                         $error = GetLang('Addon_Surveys_ErrorRequired');
                     }
                     $widgetErrors[$widget['id']][] = $error;
                     $errors++;
                 }
             }
             // validate file types
             if (isset($postWidgets[$widget['id']]) && $widget['allowed_file_types']) {
                 $typeArr = preg_split('/\\s*,\\s*/', strtolower($widget['allowed_file_types']));
                 $invalidType = false;
                 // foreach of the passed fields (most likely 1) check and see if they are valid file types
                 foreach ($postWidgets[$widget->id]['field'] as $field) {
                     $parts = explode('.', $field['value']);
                     $ext = strtolower(end($parts));
                     // only if the field has a value we will test its file type
                     if (trim($field['value']) != '' && !in_array($ext, $typeArr)) {
                         $invalidType = true;
                     }
                 }
                 // if the a file is not a valid file type, then the whole widget fails validation
                 if ($invalidType) {
                     $lastFileType = '<em>.' . array_pop($typeArr) . '</em>';
                     $firstFileTypes = '<em>.' . implode('</em>, <em>.', $typeArr) . '</em>';
                     $widgetErrors[$widget->id][] = sprintf(GetLang('errorInvalidFileType'), $firstFileTypes, $lastFileType);
                     $errors++;
                 }
             }
         }
         // if there were errors, redirect back and display the errors
         if ($errors) {
             echo '<pre style="border: 1px solid red";><b style="color:RED;">YUDI_DEBUG:' . __FILE__ . ' ON LINE: ' . __LINE__ . '</b><br />';
             print_r($widgetErrors);
             echo '</pre>';
             die;
             // set the widget errors so we can retrieve them for the user
             IEM::sessionSet('survey.addon.widgetErrors', $widgetErrors);
             IEM::sessionSet('MessageText', GetLang('Addon_Surveys_saveResponseMessageError'));
             IEM::sessionSet('MessageType', MSG_ERROR);
         } else {
             // isntantiate a new response object
             $response_api = $this->getSpecificApi('responses');
             $response_api->Load($responseId);
             // delete the values in this response, since they will be added back in
             $response_api->deleteValues();
             // if the response was saved, then associate values to the response
             if ($response_api->Save()) {
                 $responseValue = $this->getSpecificApi('responsesvalue');
                 // foreach of the posted widgets, check to see if it belongs in this form and save it if it does
                 foreach ($postWidgets as $postWidgetId => $postWidget) {
                     // iterate through each field and enter it in the feedback
                     foreach ($postWidget['field'] as $field) {
                         if (!isset($field['value'])) {
                             continue;
                         }
                         // foreign key for the response id
                         $responseValue->surveys_response_id = $responseId;
                         // set the widget id foreign key; widgets can have multiple field values and
                         // should be treated as such
                         $responseValue->surveys_widgets_id = $postWidgetId;
                         // set the value of the feedback; this should be a single value since widgets
                         // can have multiple feed back values
                         if ($field['value'] == '__other__') {
                             $responseValue->value = $field['other'];
                             $responseValue->is_othervalue = 1;
                         } else {
                             $responseValue->file_value = "";
                             if (substr($field['value'], 0, 5) == "file_") {
                                 $value = str_replace("file_", "", $field['value']);
                                 $responseValue->file_value = md5($value);
                             }
                             $responseValue->value = $field['value'];
                         }
                         // save it
                         $responseValue->Save();
                     }
                 }
                 // perform file uploading
                 if (isset($_FILES['widget']['name'])) {
                     $files = $_FILES['widget']['name'];
                     foreach ($files as $widgetId => $widget) {
                         foreach ($widget as $widgetKey => $fields) {
                             foreach ($fields as $fieldId => $field) {
                                 // gather file information
                                 $name = $_FILES['widget']['name'][$widgetId]['field'][$fieldId]['value'];
                                 $type = $_FILES['widget']['type'][$widgetId]['field'][$fieldId]['value'];
                                 $tmpName = $_FILES['widget']['tmp_name'][$widgetId]['field'][$fieldId]['value'];
                                 $error = $_FILES['widget']['error'][$widgetId]['field'][$fieldId]['value'];
                                 $size = $_FILES['widget']['size'][$widgetId]['field'][$fieldId]['value'];
                                 // if the upload was successful to the temporary folder, move it
                                 if ($error == UPLOAD_ERR_OK) {
                                     $curDir = TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'surveys';
                                     $upBaseDir = $curDir . DIRECTORY_SEPARATOR . $surveyId;
                                     $upDir = $upBaseDir . DIRECTORY_SEPARATOR . $response_api->GetId();
                                     // if the main survey folder is not yet created then create it
                                     if (!is_dir($curDir)) {
                                         mkdir($curDir, 0755);
                                     }
                                     // if the base upload directory doesn't exist create it
                                     if (!is_dir($upBaseDir)) {
                                         mkdir($upBaseDir, 0755);
                                     }
                                     // if the upload directory doesn't exist create it
                                     if (!is_dir($upDir)) {
                                         mkdir($upDir, 0755);
                                     }
                                     // upload the file
                                     move_uploaded_file($tmpName, $upDir . DIRECTORY_SEPARATOR . $name);
                                 }
                             }
                         }
                     }
                 }
                 IEM::sessionSet('MessageText', GetLang('Addon_Surveys_saveResponseMessageSuccess'));
                 IEM::sessionSet('MessageType', SS_FLASH_MSG_SUCCESS);
             }
         }
     }
     // if view is set, then go to the view page for this response
     if (!$errors && IEM::requestGetPOST('view')) {
         if (IEM::requestGetPost('viewNext')) {
             $responseId = IEM::requestGetPost('viewNext');
         }
         header('Location: index.php?Page=Addons&Addon=surveys&Action=viewresponses&surveyId=' . $surveyId . '&responseId=' . $responseId);
         exit;
     }
     // redirect back to the edit page
     header('Location: index.php?Page=Addons&Addon=surveys&Action=editresponse&surveyId=' . $surveyId . '&responseId=' . $responseId);
     exit;
 }
	/**
	* ManageCustomField_Lists
	* Prints out the custom field to list associations.
	*
	* @param Int $fieldid Fieldid to print associations for.
	* @param Boolean $newfield Whether we're creating a new field or not. This changes language variables accordingly.
	*
	* @see GetApi
	* @see CustomFields_API::Load
	* @see CustomFields_API::Settings
	* @see CustomFields_API::Associations
	* @see User_API::GetLists
	*
	* @return Void Doesn't return anything, just prints out the results.
	*/
	function ManageCustomField_Lists($fieldid=0, $newfield=false)
	{
		if ($fieldid <= 0) {
			return false;
		}

		$api = $this->GetApi();
		if (!$api->Load($fieldid)) {
			return false;
		}

		if ($newfield) {
			$GLOBALS['Heading'] = GetLang('CreateCustomField_Step3');
			$GLOBALS['Intro'] = GetLang('CreateCustomField_Step3_Intro');
			$GLOBALS['CancelButton'] = GetLang('CreateCustomField_CancelPrompt');
		} else {
			$GLOBALS['Heading'] = GetLang('EditCustomField_Step3');
			$GLOBALS['Intro'] = GetLang('EditCustomField_Step3_Intro');
			$GLOBALS['CancelButton'] = GetLang('EditCustomField_CancelPrompt');
		}

		$fieldapi = $this->GetApi('CustomFields_' . $api->fieldtype);
		$fieldapi->Load($fieldid);

		$user = IEM::getCurrentUser();
		$lists = $user->GetLists();

		$GLOBALS['fieldid'] = $fieldid;
		$GLOBALS['CustomFieldListAssociation'] = sprintf(GetLang('CustomFieldListAssociation'), $fieldapi->Settings['FieldName']);

		$list_assoc = '';

		$GLOBALS['ListAssociations'] = '';

		foreach ($lists as $listid => $listdetails) {
			$GLOBALS['ListAssociations'] .= '<option value="'. $listid . '"';

			if (in_array($listid, $fieldapi->Associations)) {
				$GLOBALS['ListAssociations'] .= ' selected="selected"';
			}
			$GLOBALS['ListAssociations'] .= '>' . htmlspecialchars($listdetails['name'], ENT_QUOTES, SENDSTUDIO_CHARSET) . '</option>';
		}

		$this->ParseTemplate('CustomField_Form_Step3');
	}
	/**
	 * _SaveCustomFields
	 * Loops through the imported custom fields for a subscribers and saves them.
	 *
	 * @param Object $SubscriberApi The Subscriber API with the existing subscriber details loaded.
	 * @param Int $subscriberid The ID of the existing or new subscriber.
	 * @param Array $customfields An array of imported custom field IDs and values.
	 * @param String $email The email address trying to be imported.
	 * @param Array $importresults The running tally of import results.
	 *
	 * @uses Subscribers_API::SaveSubscriberCustomField
	 *
	 * @return Boolean True if the custom field settings were saved succesfully, otherwise false.
	 */
	function _SaveCustomFields($SubscriberApi, $subscriberid, $customfields, $email, $importresults)
	{
		$info = '';
		foreach ($customfields as $fieldid => $fielddata) {
			if (!$SubscriberApi->SaveSubscriberCustomField($subscriberid, $fieldid, $fielddata)) {
				// This fix is for PostgreSQL (see bugid:2548).
				// If saving here failed it probably means the character set data is invalid for
				// the database. This also means we may not be able to successfully output the
				// bad data in the 'more information' box, so we'll just use the email address to
				// identify the record.
				$subf = $this->_customfields_loaded[$fieldid];
				$info .= $email . ' ' . sprintf(GetLang('InvalidCustomFieldData'), $subf->GetFieldName());
				$importresults['bads']++;
				$importresults['baddata'][] = $info;
				IEM::sessionSet('ImportResults', $importresults);
				return false;
			}
		}
		return true;
	}
	/**
	* Process
	* Works out what you're trying to do and takes appropriate action. Validates data where needed.
	*
	* @param String $action Action to perform. This is usually 'step1', 'step2', 'step3' etc. This gets passed in by the Subscribers::Process function.
	*
	* @see Subscribers::Process
	* @see GetApi
	* @see Subscribers_API::IsSubscriberOnList
	* @see Subscribers_API::AddToList
	* @see Subscribers_API::SaveSubscriberCustomField
	* @see Lists_API::GetCustomFields
	* @see CustomFields_API::IsRequired
	* @see CustomFields_API::ValidData
	* @see CustomFields_API::GetFieldName
	* @see AddSubscriber_Step2
	*
	* @return Void Prints out the step, doesn't return anything.
	*/
	function Process($action=null)
	{

		switch (strtolower($action)) {
			case 'step2':
				$listid = (isset($_POST['list'])) ? (int)$_POST['list'] : $_GET['list'];
				$this->AddSubscriber_Step2($listid);
			break;

			case 'saveadd':
			case 'save':
				$user = GetUser();

				$listid = (isset($_GET['list'])) ? (int)$_GET['list'] : 0;

				if (!$user->HasAccess('Subscribers', 'Add')) {
					$this->DenyAccess();
					return;
				}

				$user_lists = $user->GetLists();

				/**
				 * Check if user have access to the list
				 */
					if (!array($user_lists) || empty($user_lists)) {
						$this->DenyAccess();
						return;
					}

					$temp = array_keys($user_lists);
					if (!in_array($listid, $temp)) {
						$this->DenyAccess();
						return;
					}
				/**
				 * -----
				 */

				$subscriber = $this->GetApi('Subscribers');

				$email = IEM::requestGetPOST('emailaddress', '', 'trim');
				if (empty($email) || !$subscriber->ValidEmail($email)) {
					$GLOBALS['Error'] = sprintf(GetLang('SubscriberAddFail_InvalidEmailAddress'), htmlspecialchars($email));
					$GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
					$this->AddSubscriber_Step2($listid);
					break;
				}

				$duplicate = $subscriber->IsSubscriberOnList($_POST['emailaddress'], $listid);

				if ($duplicate) {
					$unsubscribed_check = $subscriber->IsUnSubscriber(false, $listid, $duplicate);
					if ($unsubscribed_check) {
						$GLOBALS['Error'] = sprintf(GetLang('SubscriberAddFail_Unsubscribed'), $_POST['emailaddress']);
					} else {
						$GLOBALS['Error'] = sprintf(GetLang('SubscriberAddFail_Duplicate'), $_POST['emailaddress']);
					}
					$GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
					$this->AddSubscriber_Step2($listid);
					break;
				}

				list($banned, $msg) = $subscriber->IsBannedSubscriber($_POST['emailaddress'], $listid, false);
				if ($banned) {
					$GLOBALS['Error'] = sprintf(GetLang('SubscriberAddFail_Banned'), $_POST['emailaddress']);
					$GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
					$this->AddSubscriber_Step2($listid);
					break;
				}

				$ListApi = $this->GetApi('Lists');
				$ListApi->Load($listid);
				$ListCustomFields = $ListApi->GetCustomFields($listid);

				$customfield_errors = array();

				foreach (array('emailaddress', 'format', 'confirmed') as $p => $area) {
					$subscriber->Set($area, $_POST[$area]);
				}
				$CustomFieldsValid = true;
				foreach ($ListCustomFields as $pos => $data) {
					$CustomFieldApi = $this->GetApi('CustomFields');
					$fieldid = $data['fieldid'];
					$CustomFieldApi->Load($fieldid);
					$postdata = (isset($_POST['CustomFields'][$fieldid])) ? $_POST['CustomFields'][$fieldid] : '';

					if (!isset($_POST['CustomFields'][$fieldid]) && !$CustomFieldApi->IsRequired()) {
						unset($CustomFieldApi);
						continue;
					}

					if ($CustomFieldApi->IsRequired()) {
						if (!$postdata) {
							$ftype = $CustomFieldApi->Get('fieldtype');
							switch ($ftype) {
								case 'text':
								case 'number':
									$errormsg = 'SubscriberAddFail_EmptyData_EnterData';
								break;

								case 'dropdown':
								case 'radiobutton':
								case 'checkbox':
								case 'date':
									$errormsg = 'SubscriberAddFail_EmptyData_ChooseOption';
								break;
							}

							$customfield_errors[] = sprintf(GetLang($errormsg), $CustomFieldApi->GetFieldName());

							unset($CustomFieldApi);

							continue;
						}
					}

					if (!$CustomFieldApi->ValidData($postdata)) {
						$customfield_errors[] = sprintf(GetLang('SubscriberAddFail_InvalidData'), $CustomFieldApi->GetFieldName());

						unset($CustomFieldApi);
						continue;
					}
					unset($CustomFieldApi);
				}

				if (!empty($customfield_errors)) {
					$GLOBALS['Error'] = implode('<br/>', $customfield_errors);
					$GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);
					$this->AddSubscriber_Step2($listid);
					break;
				}

				$subscriberid = $subscriber->AddToList($_POST['emailaddress'], $listid);
				$GLOBALS['Message'] = $this->PrintSuccess('SubscriberAddSuccessful');
				$GLOBALS['list'] = $listid;

				// go through each custom field and save the info.
				foreach ($ListCustomFields as $pos => $data) {
					$fieldid = $data['fieldid'];
					$postdata = (isset($_POST['CustomFields'][$fieldid])) ? $_POST['CustomFields'][$fieldid] : '';
					$subscriber->SaveSubscriberCustomField($subscriberid, $fieldid, $postdata);
				}

				if ($action == 'saveadd' || sizeof($user_lists) == 1) {
					$this->AddSubscriber_Step2($listid, true);
				} else {
					IEM::sessionSet('AddSubscriberMessage', $ListApi->Get('name'));
					?>
					<script>
						window.location = 'index.php?Page=Subscribers&Action=Add';
					</script>
					<?php
					exit();
				}
			break;

			default:
				$user = GetUser();
				$lists = $user->GetLists();

				// If only one list available, go directly to step 2
				if (count($lists) == 1) {
					$listid = array_pop(array_keys($lists));
					$this->AddSubscriber_Step2($listid);
				} else {
					$this->ChooseList('add', 'step2');
				}
			break;
		}
	}
示例#23
0
 /**
  * Constructor
  * Sets up the database connection.
  *
  * @return Void Does not return anything.
  */
 public function __construct()
 {
     $this->db = IEM::getDatabase();
 }
示例#24
0
$emailapi->TrackLinks(false);
$emailapi->ForceLinkChecks(false);
$emailapi->TrackOpens(false);

$emailapi->DisableUnsubscribe(true);

$emailapi->Set('CharSet', SENDSTUDIO_CHARSET);
$mail_result = $emailapi->Send(true);

/**
* Record the forward for statistical purposes.
*/
$forwardip = GetRealIp();
$forwardtime = $statsapi->GetServerTime();

$statid = IEM::sessionGet('Statid');

$forward_details = array(
	'forwardtime' => $forwardtime,
	'forwardip' => $forwardip,
	'subscriberid' => $subscriber_id,
	'statid' => $statid,
	'listid' => $list,
	'emailaddress' => $friendsemail
);

$statsapi->RecordForward($forward_details, $stats_idtype);

/**
* After all that, we'll print out the thanks message!
*/
示例#25
0
	/**
	* GetDb
	* Sets up the database object for this and the child objects to use.
	* If the Db var is already set up and the connection is a valid resource, this will return true straight away.
	* If the Db var is null or the connection is not valid, it will fetch it and store it for easy reference.
	* If it's unable to setup the database (or it's null or false) it will trigger an error.
	*
	* @see Db
	* @see IEM::getDatabase()
	*
	* @return Boolean True if it works or false if it fails. Failing also triggers a fatal error.
	*/
	function GetDb()
	{
		if (is_object($this->Db) && is_resource($this->Db->connection)) {
			return true;
		}

		if (is_null($this->Db) || !$this->Db->connection) {
			$Db = IEM::getDatabase();
			$this->Db = &$Db;
		}

		if (!is_object($this->Db) || !is_resource($this->Db->connection)) {
			trigger_error('Unable to connect to database', SENDSTUDIO_ERROR_FATAL);
			return false;
		}
		return true;
	}
	/**
	* ProcessJob
	* Processes an autoresponder queue
	* Checks a queue for duplicates, makes sure the queue is present and has recipients in it and then calls ActionJob to handle the rest
	*
	* @param Int $queueid Autoresponder queue to process. This is passed to ActionJob
	*
	* @see GetUser
	* @see RemoveDuplicatesInQueue
	* @see QueueSize
	* @see ActionJob
	* @see UnprocessQueue
	*
	* @return True Always returns true
	*/
	function ProcessJob($queueid=0)
	{
		$queueid = (int)$queueid;

		$this->user = GetUser($this->jobowner);
		IEM::userLogin($this->jobowner, false);

		$queuesize = $this->QueueSize($queueid, 'autoresponder');

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "queuesize: " . $queuesize . " for queueid " . $queueid . "\n", 3, $this->LogFile);
		}

		$jobid_query = "SELECT jobid FROM " . SENDSTUDIO_TABLEPREFIX . "jobs WHERE queueid='" . $queueid . "'";
		$jobid_result = $this->Db->Query($jobid_query);
		$jobid = $this->Db->FetchOne($jobid_result, 'jobid');

		if (!$jobid) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "no jobid (result " . gettype($jobid_result) . "; " . $jobid_result . ")" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			IEM::userLogout();
			return true;
		}

		$timenow = $this->GetServerTime();
		$query = "UPDATE " . SENDSTUDIO_TABLEPREFIX . "jobs SET lastupdatetime=" . $timenow . " WHERE jobid='" . $jobid . "'";
		$update_job_result = $this->Db->Query($query);

		if ($queuesize <= 0) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Deleting job " . $jobid . " and then returning" . "\n", 3, $this->LogFile);
			}
			$this->Db->Query("DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "jobs WHERE jobid='" . $jobid . "'");
			IEM::userLogout();
			return true;
		}

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Actioning jobid " . $jobid . "\n", 3, $this->LogFile);
		}

		$finished = $this->ActionJob($queueid, $jobid);

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Finished: " . $finished . "\n", 3, $this->LogFile);
		}

		// we need to turn 'processed' emails back to normal so we can check them next time.
		$this->UnprocessQueue($queueid);

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Deleting jobid " . $jobid . "\n", 3, $this->LogFile);
		}

		$this->Db->Query('DELETE FROM ' . SENDSTUDIO_TABLEPREFIX . 'jobs_lists WHERE jobid=' . intval($jobid));
		$this->Db->Query("DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "jobs WHERE jobid=" . intval($jobid));

		IEM::userLogout();
		return true;
	}
示例#27
0
	/**
	* ShowStep_4
	* This prints the "upgrade failed" message to send to interspire if something went wrong.
	*
	* @return Void Prints the page out, doesn't return it.
	*/
	function ShowStep_4()
	{
		$errors = IEM::sessionGet('DatabaseUpgradesFailed');

		$errorReport = "Interspire Email Marketer Upgrade Error Report\n";
		$errorReport .= "----------------------------------------------\n";
		$errorReport .= gmdate("r")."\n";
		$errorReport .= "\n";
		$errorReport .= "Application URL: ".SENDSTUDIO_APPLICATION_URL."\n";
		$errorReport .= "Contact Email: ".SENDSTUDIO_EMAIL_ADDRESS."\n";
		$errorReport .= "\n";

		$errorReport .= "Upgrade Details:\n";
		$errorReport .= "----------------\n";
		$errorReport .= "Upgrade From: ".IEM::sessionGet('PreviousVersion')." (".IEM::sessionGet('PreviousDBVersion').")\n";
		$errorReport .= "Upgrade To: ".GetLang('SENDSTUDIO_VERSION')." (".SENDSTUDIO_DATABASE_VERSION.")\n";
		$errorReport .= "\n";

		$errorReport .= "Upgrade Error:\n";
		$errorReport .= "----------------\n";
		$errorReport .= implode("\n", $errors);
		$errorReport .= "\n";
		$errorReport .= "\n";

		$errorReport .= "Server Information:\n";
		$errorReport .= "---------------------\n";
		$errorReport .= "PHP Version: ".phpversion()."\n";
		$errorReport .= "Database Type: ".SENDSTUDIO_DATABASE_TYPE."\n";
		$errorReport .= "Database Version: ".SENDSTUDIO_SYSTEM_DATABASE_VERSION."\n";

		$this->PrintHeader();
		?>
		<br /><br /><br /><br />
		<table style="margin:auto;"><tr><td style="border:solid 2px #DDD; padding:20px; background-color:#FFF; width:450px">
		<table>
			<tr>
				<td class="Heading1">
						<img src="images/logo.jpg" />
				</td>
			</tr>
			<tr>
				<td style="padding:10px 0px 5px 0px">
						<strong><?php echo GetLang('Upgrade_Errors_Heading'); ?></strong>
						<p><?php echo GetLang('Upgrade_Errors_Message'); ?></p>
						<textarea class="Field400" style="width: 100%" rows="10" cols="20" onfocus="this.select();"><?php echo $errorReport; ?></textarea>
				</td>
			</tr>
		</table>
		</td></tr></table>
		<?php
		$this->PrintFooter();
	}
示例#28
0
	/**
	 * Pauses autoresponder
	 * @param integer $autoresponderid Autoresponder to be paused
	 * @return boolean Returns TRUE if successful, FALSE otherwise
	 */
	function PauseAutoresponder($autoresponderid)
	{
		$user = IEM::getCurrentUser();
		$autoresponderid = intval($autoresponderid);
		$userid = $user->userid;

		if ($userid == 0) {
			trigger_error(__CLASS__ . '::' . __METHOD__ . ' -- You need to login first before you can pause autoresponder', E_USER_NOTICE);
			return false;
		}

		$status = $this->Db->Query("UPDATE [|PREFIX|]autoresponders SET pause = {$userid} WHERE autoresponderid = {$autoresponderid}");
		if (!$status) {
			return false;
		}

		return true;
	}
    /**
     * DisplayEditNewsletter
     * Prints out the editor for stage 2 of editing a newsletter (the wysiwyg area or textarea depending on the format chosen in stage 1). If you have selected a template in the previous step, the content from that template will be displayed here.
     *
     * @param Int $newsletterid Newsletter to load up. If there is one, it will pre-load that content. If there is no newsletterid, it displays a blank area to create your content.
     *
     * @see CreateNewsletter
     * @see EditNewsletter
     * @see GetApi
     * @see Newsletter_API::Load
     * @see Newsletter_API::GetBody
     * @see GetAttachments
     * @see FetchEditor
     *
     * @return Void Prints out the form, doesn't return anything.
     */
    function DisplayEditNewsletter($newsletterid=0) {
        $newsletter = $this->GetApi();
        $newslettercontents = array('text' => '', 'html' => '');

        $user = GetUser();

        $GLOBALS['FromPreviewEmail'] = $user->Get('emailaddress');

        $GLOBALS['DisplayAttachmentsHeading'] = 'none';

        $tpl = GetTemplateSystem();


        if ($newsletterid > 0) {
            $GLOBALS['SaveAction'] = 'Edit&SubAction=Save&id=' . $newsletterid;
            $GLOBALS['Heading'] = GetLang('EditNewsletter');
            $GLOBALS['Intro'] = GetLang('EditNewsletterIntro_Step2');
            $GLOBALS['Action'] = 'Edit&SubAction=Complete&id=' . $newsletterid;
            $GLOBALS['CancelButton'] = GetLang('EditNewsletterCancelButton');

            $newsletter->Load($newsletterid);
            $GLOBALS['IsActive'] = ($newsletter->Active()) ? ' CHECKED' : '';
            $GLOBALS['Archive'] = ($newsletter->Archive()) ? ' CHECKED' : '';
            $newslettercontents['text'] = $newsletter->GetBody('text');
            $newslettercontents['html'] = $newsletter->GetBody('html');

            $GLOBALS['Subject'] = htmlspecialchars($newsletter->subject, ENT_QUOTES, SENDSTUDIO_CHARSET);
        } else {
            $GLOBALS['SaveAction'] = 'Create&SubAction=Save&id=' . $newsletterid;
            $GLOBALS['Heading'] = GetLang('CreateNewsletter');
            $GLOBALS['Intro'] = GetLang('CreateNewsletterIntro_Step2');
            $GLOBALS['Action'] = 'Create&SubAction=Complete';
            $GLOBALS['CancelButton'] = GetLang('CreateNewsletterCancelButton');

            $GLOBALS['IsActive'] = ' CHECKED';
            $GLOBALS['Archive'] = ' CHECKED';
        }

        if (!SENDSTUDIO_ALLOW_ATTACHMENTS) {
            $tpl->Assign('ShowAttach', false);
            $GLOBALS['DisplayAttachments'] = 'none';
            $user = IEM::getCurrentUser();
            if ($user) {
                if ($user->isAdmin()) {
                    $GLOBALS['AttachmentsMsg'] = GetLang('NoAttachment_Admin');
                } else {
                    $GLOBALS['AttachmentsMsg'] = GetLang('NoAttachment_User');
                }
            }
        } else {
            $tpl->Assign('ShowAttach', true);
            $attachmentsarea = strtolower(get_class($this));
            $attachments_list = $this->GetAttachments($attachmentsarea, $newsletterid);
            $GLOBALS['AttachmentsList'] = $attachments_list;
        }

        $GLOBALS['PreviewID'] = $newsletterid;
        // we don't really need to get/set the stuff here.. we could use references.
        // if we do though, it segfaults! so we get and then set the contents.
        $session_newsletter = IEM::sessionGet('Newsletters');
        $session_newsletter['id'] = (int) $newsletterid;

        if (isset($session_newsletter['TemplateID'])) {
            $templateApi = $this->GetApi('Templates');
            if (is_numeric($session_newsletter['TemplateID'])) {
                $templateApi->Load($session_newsletter['TemplateID']);
                $newslettercontents['text'] = $templateApi->textbody;
                $newslettercontents['html'] = $templateApi->htmlbody;
            } else {
                $newslettercontents['html'] = $templateApi->ReadServerTemplate($session_newsletter['TemplateID']);
            }
            unset($session_newsletter['TemplateID']);
        }

        $session_newsletter['contents'] = $newslettercontents;
        IEM::sessionSet('Newsletters', $session_newsletter);
        $editor = $this->FetchEditor();
        $GLOBALS['Editor'] = $editor;

        $user = GetUser();
        if ($user->group->forcespamcheck) {
            $GLOBALS['ForceSpamCheck'] = 1;
        }

        $tpl->ParseTemplate('Newsletter_Form_Step2');
    }
示例#30
0
	/**
	* ManageImages
	* Perform the action to display the UI for managing Images.
	*
	* @param Interger $userid The user id of current login user.
	*
	* @return Void Doesn't return anything. Display the template to the browser.
	*/
	function ManageImages () {
		$api = $this->GetApi();
		$settingApi = $this->GetApi('settings');
		$GLOBALS['adminUrl'] = SENDSTUDIO_APPLICATION_URL.'/admin';
		$GLOBALS['imgLocation'] = $api->GetImageDir();
		$params = '';
		foreach ($_GET as $k=>$v) {
			$params[] = $k.'='.$v;
		}
		if ($params) {
			$params = '?'.implode('&', $params);
		}

		$tpl = GetTemplateSystem();
		$tpl->Assign('SessionName', IEM::SESSION_NAME);
		$tpl->Assign('SessionID', IEM::sessionID());
		$tpl->Assign('Params', $params);
		echo $tpl->ParseTemplate('Image_Manage');
		die();
	}