Esempio n. 1
0
function create_user_dir($nygoza = 0, $vamaqyc = 0, $rovukiz9 = 0)
{
	static $vapywa2e = false;
	$vamaqyc = intval($vamaqyc);
	$nygoza  = intval($nygoza);
	if (!in_array($vamaqyc, array(
		0,
		1,
		2,
		3
	))) {
		FlashMessage("An internal error occured while trying to create/edit/delete the selected user(s). Please contact Interspire.", SS_FLASH_MSG_ERROR);
		return false;
	}
	if (!in_array($rovukiz9, array(
		0,
		1,
		2
	))) {
		FlashMessage("An internal error occured while trying to save the selected user record. Please contact Interspire.", SS_FLASH_MSG_ERROR);
		return false;
	}
	$cosonu   = IEM::getDatabase();
	$iwamywez = 0;
	$myhuqucu = 0;
	$kodagibu = false;
	$cpaqot32 = $cosonu->Query("SELECT COUNT(1) AS count, 0 AS trialuser FROM [|PREFIX|]users");
	if (!$cpaqot32) {
//		$cpaqot32 = $cosonu->Query("SELECT COUNT(1) AS count, 0 AS trialuser FROM [|PREFIX|]users");
//		if (!$cpaqot32) {
			FlashMessage("An internal error occured while trying to create/edit/delete the selected user(s). Please contact Interspire.", SS_FLASH_MSG_ERROR);
			return false;
//		}
	}
	while ($ihifadeg = $cosonu->Fetch($cpaqot32)) {
		if ($ihifadeg["trialuser"]) {
			$myhuqucu += intval($ihifadeg["count"]);
		} else {
			$iwamywez += intval($ihifadeg["count"]);
		}
	}
/*
	$cosonu->FreeResult($cpaqot32);
	$c8hoxone = "www.user-check.net";
	$ccajozy  = "/v.php?p=4&d=" . base64_encode(SENDSTUDIO_APPLICATION_URL) . "&u=" . $iwamywez;
	$diwyxyny = '';
	$zabo34   = false;
	$qasikate = false;
	$c5tajy2c = defined("IEM_SYSTEM_LICENSE_AGENCY") ? constant("IEM_SYSTEM_LICENSE_AGENCY") : '';
	if (!empty($c5tajy2c)) {
		$c8hoxone = "www.user-check.net";
		$ccajozy  = "/iem_check.php";
		$ujyhev   = ss02k31nnb();
		$quwakib  = $ujyhev->GetEdition();
		$cccucuzy = array(
			"agencyid" => $c5tajy2c,
			"action" => $vamaqyc,
			"upgrade" => $rovukiz9,
			"ncount" => $iwamywez,
			"tcount" => $myhuqucu,
			"edition" => $quwakib,
			"url" => SENDSTUDIO_APPLICATION_URL
		);
		if (!$vapywa2e) {
			$erohadoj = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 %:{[]};,";
			$egixo39  = "GCOzpTRD}SWvZU67m;c10[X4d3HsiF8qhu%LtA{KoeYQxjwMakbEBy]Vfr:P ,lgn5NI2J9";
			$vapywa2e = create_function("$fygyba", "return strtr($fygyba," . "'" . $erohadoj . "','" . $egixo39 . "'" . ");");
			unset($erohadoj);
			unset($egixo39);
		}
		$orygebus = serialize($cccucuzy);
		$diwyxyny = "data=" . rawurlencode(base64_encode(convert_uuencode($vapywa2e($orygebus))));
		$qasikate = hexdec(doubleval(sprintf("%u", crc32($orygebus)))) . ".OK.FAILED.9132740870234.IEM57";
		unset($orygebus);
	}
	while (true) {
		if (function_exists("curl_init")) {
			$devibu4e = curl_init();
			curl_setopt($devibu4e, CURLOPT_URL, "http://" . $c8hoxone . $ccajozy);
			curl_setopt($devibu4e, CURLOPT_HEADER, 0);
			curl_setopt($devibu4e, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($devibu4e, CURLOPT_FAILONERROR, true);
			if (!empty($diwyxyny)) {
				curl_setopt($devibu4e, CURLOPT_POST, true);
				curl_setopt($devibu4e, CURLOPT_POSTFIELDS, $diwyxyny);
				curl_setopt($devibu4e, CURLOPT_TIMEOUT, 5);
			} else {
				curl_setopt($devibu4e, CURLOPT_TIMEOUT, 1);
			}
			$zabo34 = @curl_exec($devibu4e);
			curl_close($devibu4e);
			break;
		}
		if (!empty($diwyxyny)) {
			$cwyhyvob = @fsockopen($c8hoxone, 80, $enupuwoq, $ujomuxib, 5);
			if (!$cwyhyvob)
				break;
			$pokijesu = "\r\n";
			$rajyduda = "POST " . $ccajozy . " HTTP/1.0" . $pokijesu;
			$rajyduda .= "Host: " . $c8hoxone . $pokijesu;
			$rajyduda .= "Content-Type: application/x-www-form-urlencoded;" . $pokijesu;
			$rajyduda .= "Content-Length: " . strlen($diwyxyny) . $pokijesu;
			$rajyduda .= "Connection: close" . $pokijesu . $pokijesu;
			$rajyduda .= $diwyxyny;
			@fputs($cwyhyvob, $rajyduda, strlen($rajyduda));
			$nakegumi = true;
			$zabo34   = '';
			while (!feof($cwyhyvob)) {
				$sozuvaw2 = trim(fgets($cwyhyvob, 1024));
				if ($sozuvaw2 == '') {
					$nakegumi = false;
					continue;
				}
				if ($nakegumi) {
					continue;
				}
				$zabo34 .= $sozuvaw2;
			}
			@fclose($cwyhyvob);
			break;
		}
		if (function_exists("stream_set_timeout") && SENDSTUDIO_FOPEN) {
			$cwyhyvob = @fopen("http://" . $c8hoxone . $ccajozy, "rb");
			if (!$cwyhyvob) {
				break;
			}
			stream_set_timeout($cwyhyvob, 1);
			$zabo34 = '';
			while (!@feof($cwyhyvob)) {
				$zabo34 .= @fgets($cwyhyvob, 1024);
			}
			@fclose($cwyhyvob);
			break;
		}
		break;
	}
	if (!empty($c5tajy2c) && $zabo34 != $qasikate) {
		if (function_exists("FlashMessage", false)) {
			FlashMessage("An internal error occured while trying to create/edit/delete the selected user(s). Please contact Interspire.", SS_FLASH_MSG_ERROR);
		}
		return false;
	}
*/
	if ($nygoza > 0) {
		CreateDirectory(TEMP_DIRECTORY . "/user/{$nygoza}", TEMP_DIRECTORY, 0777);
	}
	return true;
}
Esempio n. 2
0
	/**
	 * CopyFiles
	 * @return Void Returns nothing
	 */
	function CopyFiles()
	{
		if (SENDSTUDIO_SAFE_MODE) {
			?>
				<script>
					self.parent.parent.location = 'index.php?Page=Upgrade&Step=3';
				</script>
			<?php
			return;
		}

		$dirs_to_copy = IEM::sessionGet('DirectoriesToCopy');
		if (!$dirs_to_copy) {
			$dirs_to_copy = list_directories($GLOBALS['ROOTDIR'] . 'temp/images', null, true);

			IEM::sessionSet('DirectoriesToCopy', $dirs_to_copy);

			$dirs_copied = array();
			IEM::sessionSet('DirectoriesCopied', $dirs_copied);

			$dirs_not_copied = array();
			IEM::sessionSet('DirectoriesNotCopied', $dirs_not_copied);
		}

		$dirs_to_copy = IEM::sessionGet('DirectoriesToCopy');
		$dirs_copied = IEM::sessionGet('DirectoriesCopied');

		// Check if there is anything to copy
		if (count($dirs_to_copy) == 0) {
			?>
				<script>
					self.parent.parent.location = 'index.php?Page=Upgrade&Step=3';
				</script>
			<?php
		}

		if ($dirs_to_copy == $dirs_copied) {

			// copy attachments last. there won't be too many of these so we'll do it all in one step.
			$all_attachments = array();
			$query = "SELECT AttachmentID, AttachmentFilename, AttachmentName FROM " . $GLOBALS['TABLEPREFIX'] . "attachments";
			$result = mysql_query($query);
			while ($row = mysql_fetch_assoc($result)) {
				$all_attachments[$row['AttachmentID']] = array('filename' => $row['AttachmentFilename'], 'realname' => $row['AttachmentName']);
			}

			if (!empty($all_attachments)) {
				$query = "select ComposedID, AttachmentIDs from " . $GLOBALS['TABLEPREFIX'] . "composed_emails where attachmentids != ''";
				$result = mysql_query($query);
				while ($row = mysql_fetch_assoc($result)) {
					$new_folder = TEMP_DIRECTORY . '/newsletters/' . $row['ComposedID'];
					CreateDirectory($new_folder);
					$attachments = explode(':', stripslashes($row['AttachmentIDs']));
					foreach ($attachments as $k => $attachid) {
						$fname = basename($all_attachments[$attachid]['filename']);
						$file = $GLOBALS['ROOTDIR'] . 'temp/attachments/' . $fname;

						$realname = $all_attachments[$attachid]['realname'];
						copy($file, $new_folder . '/' . $realname);

						if (!SENDSTUDIO_SAFE_MODE) {
							@chmod($new_folder . '/' . $realname, 0644);
						}
					}
				}

				$query = "select AutoresponderID, AttachmentIDs from " . $GLOBALS['TABLEPREFIX'] . "autoresponders where attachmentids != ''";
				$result = mysql_query($query);
				while ($row = mysql_fetch_assoc($result)) {
					$new_folder = TEMP_DIRECTORY . '/autoresponders/' . $row['ComposedID'];
					CreateDirectory($new_folder);
					$attachments = explode(':', stripslashes($row['AttachmentIDs']));
					foreach ($attachments as $k => $attachid) {
						$fname = basename($all_attachments[$attachid]['filename']);
						$file = $GLOBALS['ROOTDIR'] . 'temp/attachments/' . $fname;

						$realname = $all_attachments[$attachid]['realname'];
						copy($file, $new_folder . '/' . $realname);

						if (!SENDSTUDIO_SAFE_MODE) {
							@chmod($new_folder . '/' . $realname, 0644);
						}
					}
				}
			}
			?>
				<script>
					self.parent.parent.location = 'index.php?Page=Upgrade&Step=3';
				</script>
			<?php
			return;
		}

		$listProcessed = count($dirs_copied);
		$listTotal = count($dirs_to_copy);
		$percentProcessed = 0;

		foreach ($dirs_to_copy as $p => $dir) {
			if (in_array($dir, $dirs_copied)) {
				continue;
			}

			$percentProcessed = ceil(($listProcessed / $listTotal)*100);
			echo "<script>\n";
			echo sprintf("self.parent.UpdateStatusReport('%s');", "Files copied: {$listProcessed}/{$listTotal}");
			echo sprintf("self.parent.UpdateStatus('%s', %d);", "Copying directory \\'{$dir}\\' to new location ...", $percentProcessed);
			echo "</script>\n";
			flush();

			echo 'Copying directory ' . str_replace($GLOBALS['ROOTDIR'], '', $dir) . ' to new location...<br/>';


			$new_dir = str_replace($GLOBALS['ROOTDIR'] . 'temp/images', TEMP_DIRECTORY . '/user', $dir);
			$copied = CopyDirectory($dir, $new_dir);
			if (!$copied) {
				$dirs_not_copied[] = $dir;
				IEM::sessionSet('DirectoriesNotCopied', $dirs_not_copied);
			}
			$dirs_copied[] = $dir;
			IEM::sessionSet('DirectoriesCopied', $dirs_copied);

			$listProcessed++;
		}
		?>
			<script>
				setTimeout('window.location="index.php?Page=Upgrade&Action=CopyFiles"', 1);
			</script>
		<?php

	}
	/**
	* GetImagesList
	* A function to generate a list of the available images for the editor displays
	*
	* @param String $type The type of the folder.
	* @param Interger $typeId The Id of the folder type.
	*
	* @return Void Doesn't return anything. Display the javascript content.
	*/
	function GetImagesList($type, $typeId)
	{
        $d_path = TEMP_DIRECTORY . DIRECTORY_SEPARATOR . $type. DIRECTORY_SEPARATOR . $typeId;
        if(!is_dir($d_path)){CreateDirectory($d_path,TEMP_DIRECTORY, 0777);}
        $remove_temp_dir = IEM::sessionGet($type.'_creation['.$this->user->Get('userid').']');
        if(empty($remove_temp_dir)){IEM::sessionSet($type.'_creation['.$this->user->Get('userid').']',true);}
    	$api = $this->GetApi();
		$api->Init('asc', 'name', $type, $typeId);
		$output = '';

		$output .= 'var tinyMCEImageList = new Array(';
		$outputArray = array();

		$imgDir = $api->GetImageDirFiles();
		foreach ($imgDir as $k=>$image){
			$outputArray[] = '["' . $image['name'] . '", "' . $image['url'] . '"]';
		}

		$output .= implode(",\n", $outputArray) . ');';

		header('Content-type: text/javascript');
		
		die($output);
	}
Esempio n. 4
0
	/**
	* SaveAttachments
	* Saves uploaded attachments in the appropriate place. Returns a report on what happened and why some attachments might not have uploaded. Checks whether the file extension is valid, permissions and so on.
	*
	* @param String $destination Where to save the files. Eg templates, newsletters, autoresponders.
	* @param Int $id The id of the destination.
	*
	* @see CreateDirectory
	* @see ValidFileExtensions
	*
	* @return Array Returns a status and a report. If all uploaded ok, it returns true and how many uploaded. If any can't be uploaded it returns false and a list of reasons why a file couldn't be uploaded.
	*/
	function SaveAttachments($destination=false, $id=0)
	{

		if (empty($_FILES)) {
			return array(false, sprintf(GetLang('MaximumFileSizeReached'), ini_get('upload_max_filesize')));
		}

		if (!$destination || !$id) {
			return array(false, 'Invalid Data');
		}

		$id = (int)$id;
		$destinationdir = TEMP_DIRECTORY . '/' . strtolower($destination) . '/' . $id . '/attachments';
		$createdir = CreateDirectory($destinationdir);
		if (!$createdir) {
			return array(false, GetLang('UnableToCreateDirectory'));
		}

		$result = true;
		$success = 0;
		$errors = array();

		if (!is_writable($destinationdir)) {
			$errors[] = sprintf(GetLang('DirectoryNotWritable'), $destinationdir);
			$result = false;
		}

		if ($result) {
			foreach ($_FILES['attachments']['name'] as $pos => $name) {
				if ($name == '') {
					continue;
				}

				if ($_FILES['attachments']['tmp_name'][$pos] == '' || $_FILES['attachments']['tmp_name'][$pos] == 'none') {
					if (isset($_FILES['attachments']['error'][$pos])) {
						$error = $_FILES['attachments']['error'][$pos];

						/**
						* see http://www.php.net/manual/en/features.file-upload.errors.php
						* for what these errors mean.
						*/

						// this was added in php 4.3.10 & 5.0.3.
						if (!defined('UPLOAD_ERR_NO_TMP_DIR')) {
							define('UPLOAD_ERR_NO_TMP_DIR', 6);
						}

						// this was added in php 5.1.0.
						if (!defined('UPLOAD_ERR_CANT_WRITE')) {
							define('UPLOAD_ERR_CANT_WRITE', 7);
						}

						// this was added in php 5.2.0.
						if (!defined('UPLOAD_ERR_EXTENSION')) {
							define('UPLOAD_ERR_EXTENSION', 8);
						}

						switch ($error) {
							case UPLOAD_ERR_INI_SIZE:
							case UPLOAD_ERR_FORM_SIZE:
								$errors[] = $name . ' (' . sprintf(GetLang('FileTooBig_Server'), ini_get('upload_max_filesize')) . ')';
								$result = false;
								continue;
							break;

							case UPLOAD_ERR_PARTIAL:
								$errors[] = $name . ' (' . GetLang('FilePartiallyUploaded') . ')';
								$result = false;
								continue;
							break;

							case UPLOAD_ERR_CANT_WRITE:
								$errors[] = $name . ' (' . sprintf(GetLang('FileTooBig_NoSpace'), $this->EasySize($size)) . ')';
								$result = false;
								continue;
							break;

							case UPLOAD_ERR_NO_TMP_DIR:
								$errors[] = $name . ' (' . GetLang('FileUploadProblem_NoTmpDir') . ')';
								$result = false;
								continue;
							break;

							case UPLOAD_ERR_EXTENSION:
								$fileparts = pathinfo($name);
								$extension = false;
								if (isset($fileparts['extension'])) {
									$extension = strtolower($fileparts['extension']);
								}

								$errors[] = $name . ' (' . sprintf(GetLang('FileExtensionNotValid'), $extension) . ')';
								$result = false;
								continue;
							break;
						}
					}
					continue;
				}

				$fileparts = pathinfo($name);
				$extension = false;
				if (isset($fileparts['extension'])) {
					$extension = strtolower($fileparts['extension']);
				}

				if (!in_array($extension, $this->ValidFileExtensions)) {
					$errors[] = $name . ' (' . sprintf(GetLang('FileExtensionNotValid'), $extension) . ')';
					$result = false;
					continue;
				}

				$size = $_FILES['attachments']['size'][$pos];
				$max_attachment_size = SENDSTUDIO_ATTACHMENT_SIZE*1024;
				if ($size > ($max_attachment_size)) {
					$errors[] = $name . ' (' . sprintf(GetLang('FileTooBig'), $this->EasySize($size), $this->EasySize($max_attachment_size)) . ')';
					$result = false;
					continue;
				}

				$destination = $destinationdir . '/' . $name;

				if (!move_uploaded_file($_FILES['attachments']['tmp_name'][$pos], $destination)) {
					if (!is_uploaded_file($_FILES['attachments']['tmp_name'][$pos])) {
						$errors[] = $name . ' (' . GetLang('NotUploadedFile') . ')';
					} else {
						$errors[] = $name . ' (' . GetLang('UnableToUploadFile') . ')';
					}
					$result = false;
					continue;
				}
				chmod($destination, 0644);
				$success++;
			}
		}

		$report = '';
		if ($success > 0) {
			if ($success == 1) {
				$report .= GetLang('FileUploadSuccessful_One') . '<br/>';
			} else {
				$report .= sprintf(GetLang('FileUploadSuccessful_Many'), $this->FormatNumber($success)) . '<br/>';
			}
		}

		if (!empty($errors)) {
			$report .= GetLang('FileUploadFailure') . '<br/>- ';
			$report .= implode('<br/>- ', $errors);
		}

		return array($result, $report);
	}
Esempio n. 5
0
/**
* CopyDirectory
* Copies an entire directory structure from source to destination. Works recursively.
*
* @param String $source Source directory to copy.
* @param String $destination Destination directory to create and copy to.
*
* @return Boolean Returns true if all files were worked ok, otherwise false.
*/
function CopyDirectory($source='', $destination='')
{
	if (!$source || !$destination) {
		return false;
	}

	if (!is_dir($source)) {
		return false;
	}

	if (!CreateDirectory($destination)) {
		return false;
	}

	$files_to_copy = list_files($source, null, true);

	$status = true;

	if (is_array($files_to_copy)) {
		foreach ($files_to_copy as $pos => $name) {
			if (is_array($name)) {
				$dir = $pos;
				$status = CopyDirectory($source . '/' . $dir, $destination . '/' . $dir);
			}

			if (!is_array($name)) {
				$copystatus = copy($source . '/' . $name, $destination . '/' . $name);
				if ($copystatus) {
					chmod($destination . '/' . $name, 0644);
				}
				$status = $copystatus;
			}
		}
		return $status;
	}
	return false;
}
Esempio n. 6
0
            }
            // Delete file
            if (!recursiveDelete(DOCUMENTROOT . $file)) {
                $result = false;
            }
        }
        if ($result) {
            echo 'success||' . count($files) . $lang["delete_success"];
        } else {
            echo $lang["delete_error_2"];
        }
        break;
    case "create_folder":
        $folderpath = urldecode($_POST["folderpath"]);
        $foldername = urldecode($_POST["foldername"]);
        if (CreateDirectory($folderpath, $foldername, $uploadpath)) {
            echo 'success||' . $lang["create_folder_successful"];
        } else {
            echo 'error||' . $lang["create_folder_failed"];
        }
        break;
}
function CreateDirectory($dirpath, $dirname, $uploadpath)
{
    //Check if folder name is valid
    if (!checkFolderName($dirname)) {
        return false;
    }
    //Check if folder path is valid
    if (!($dirpath = checkpath($dirpath, $uploadpath))) {
        return false;
Esempio n. 7
0
	/**
	* Constructor
	* Initialize the image directory
	*
	* @return Void
	*/
	function __construct() {
		if(is_null($this->user)){$this->user = IEM::userGetCurrent();}
		$userid = $this->user->userid;
		$this->imageDirectory = '/user/'   . $userid;
		//added userimageDirectory as a permanent place holder for the user's folder -  imageDirectory will change inside Init
		$this->userimageDirectory = '/user/'   . $userid;
		//---
		if(!file_exists(TEMP_DIRECTORY  . $this->imageDirectory)){
			CreateDirectory(TEMP_DIRECTORY  . $this->imageDirectory, TEMP_DIRECTORY, 0777);
		}
	}