Ejemplo n.º 1
0
bool MCServerGetSessionIdFromCookie(char *&r_id)
{
	MCVariable *t_cookie_array;
	t_cookie_array = MCVariable::lookupglobal_cstring("$_COOKIE");
	
	if (t_cookie_array == NULL)
	{
		r_id = NULL;
		return true;
	}
	
	// ensure cookie array is evaluated
	if (t_cookie_array->isdeferred() && ES_NORMAL != ((MCDeferredVariable*)t_cookie_array)->compute())
		return false;
	
	MCExecPoint ep;
	if (ES_NORMAL != t_cookie_array->fetch_element(ep, MCS_get_session_name()))
		return false;
	
	// retrieve ID from cookie value
	if (ep.isempty())
		r_id = NULL;
	else
		r_id = ep.getsvalue().clone();
	
	return true;
}
Ejemplo n.º 2
0
void MCS_ntoa(MCExecPoint& ep, MCExecPoint& ep2)
{
	if (!ep2.isempty())
	{
		MCresult -> sets("not supported");
		return;
	}
	
	char *t_hostname;
	t_hostname = ep . getsvalue() . clone();
	strtok(t_hostname, "|:");
	
	ep . clear();
	if (!MCsystem -> HostNameToAddress(t_hostname, MCS_resolve_callback, &ep))
		MCresult -> sets("invalid host name");
	else
		MCresult -> clear();
	
	delete t_hostname;
}
Ejemplo n.º 3
0
// MW-2005-05-15: Updated for new answer command restructuring
int MCA_folder(MCExecPoint &ep, const char *p_title, const char *p_prompt, const char *p_initial, unsigned int p_options)
{
	if (MCmajorosversion >= 0x0600 && MCModeMakeLocalWindows())
		return MCA_file(ep, p_title, p_prompt, nil, p_initial, p_options | MCA_OPTION_FOLDER_DIALOG);

// MW-2005-05-27: We'll use a static (I know bad me) to store the version
//   of the shell dll.
	static int s_shell_version = -1;
	static char *s_last_folder = NULL;

	char *t_native_filename;
	unsigned int t_native_filename_length;

	if (p_initial != NULL)
	{
		t_native_filename_length = strlen(p_initial);
		t_native_filename = (char *)_alloca(t_native_filename_length + 2);
		strcpy(t_native_filename, p_initial);
		MCU_path2native(t_native_filename);
	}
	else
	{
		t_native_filename = s_last_folder;
		t_native_filename_length = 0;
	}

	if (!MCModeMakeLocalWindows())
	{
		MCRemoteFolderDialog(ep, p_title, p_prompt, t_native_filename);
		if (!ep.isempty())
		{
			if (s_last_folder != NULL)
				delete s_last_folder;
			s_last_folder = ep.getsvalue().clone();
			MCU_path2native(s_last_folder);
		}
		return 0;
	}

	if (s_shell_version == -1)
		s_shell_version = get_dll_version("shell32.dll");

	bool sheet = (p_options & MCA_OPTION_SHEET) != 0;
	char *prompt = (char *)p_prompt;
	
	ep . clear();

	BROWSEINFOA bi;
	memset(&bi, 0, sizeof(BROWSEINFO));

	Window pw;
	pw = MCModeGetParentWindow();

	if (pw != DNULL)
		bi.hwndOwner = (HWND)pw->handle.window;

	bi.pidlRoot = NULL;
	bi.lpszTitle = prompt;
	bi.ulFlags = BIF_RETURNONLYFSDIRS;
	if (s_shell_version >= 500)
		bi.ulFlags |= BIF_NEWDIALOGSTYLE;
	if (t_native_filename != NULL)
	{
		bi . lpfn = BrowseCallbackProc;
		bi . lParam = (LPARAM)t_native_filename;
	}
	else
	{
		bi.lpfn = NULL;
		bi.lParam = NULL;
	}
	LPITEMIDLIST lpiil;
	LPMALLOC lpm;
	char *tdir = NULL;
	SHGetMalloc(&lpm);

	DWORD t_error;
	lpiil = SHBrowseForFolderA(&bi);
	if (lpiil == NULL)
	{
		t_error = GetLastError();
	}
	
	if (lpiil != NULL && SHGetPathFromIDListA(lpiil, ep.getbuffer(PATH_MAX)))
	{
		if (s_last_folder != NULL)
			delete s_last_folder;
		s_last_folder = strclone(ep . getbuffer(0));
		MCU_path2std(ep.getbuffer(0));
		ep.setstrlen();
	}
	else
	{
		ep.clear();
		MCresult->sets(MCcancelstring);
	}
	//  SMR 1880 clear shift and button state
	waitonbutton();

	lpm->Free(lpiil);
	lpm->Release();

	return 0;
}
Ejemplo n.º 4
0
Exec_stat MCPut::exec_cookie(MCExecPoint &ep)
{
	char *t_name = NULL;
	char *t_value = NULL;
	char *t_path = NULL;
	char *t_domain = NULL;
	
	uint32_t t_name_len = 0;
	uint32_t t_value_len = 0;
	uint32_t t_path_len = 0;
	uint32_t t_domain_len = 0;
	
	uint32_t t_expires = 0;
	
	bool t_success = true;
	
	
	t_value = ep.getsvalue().clone();
	t_value_len = ep.getsvalue().getlength();
	
	t_success = (ES_NORMAL == name->eval(ep));
	
	if (t_success)
	{
		t_name = ep.getsvalue().clone();
		t_name_len = ep.getsvalue().getlength();
		if (expires != NULL)
			t_success = expires->eval(ep);
	}
	if (t_success && expires)
		t_success = ep.isempty() || MCU_stoui4(ep.getsvalue(), t_expires);
	
	if (t_success && path)
	{
		t_success = path->eval(ep);
		if (t_success)
		{
			t_path = ep.getsvalue().clone();
			t_path_len = ep.getsvalue().getlength();
		}
	}
	
	if (t_success && domain)
	{
		t_success = domain->eval(ep);
		if (t_success)
		{
			t_domain = ep.getsvalue().clone();
			t_domain_len = ep.getsvalue().getlength();
		}
	}
		
	if(t_success)
		t_success = MCServerSetCookie(MCString(t_name, t_name_len), MCString(t_value, t_value_len), t_expires, MCString(t_path, t_path_len), MCString(t_domain, t_domain_len), is_secure, is_httponly);

	MCCStringFree(t_name);
	MCCStringFree(t_value);
	MCCStringFree(t_path);
	MCCStringFree(t_domain);

	if (!t_success)
	{
		MCeerror->add(EE_PUT_CANTSETINTO, line, pos);
		return ES_ERROR;
	}
	ep.clear();
	return ES_NORMAL;
}