Jump to content

Dug

Members
  • Content Count

    50
  • Joined

  • Last visited

Community Reputation

1 Neutral

About Dug

  • Rank
    Newbie
  • Birthday 05/19/1983

Previous Fields

  • Languages
    ASP, SQL, HTML, CSS, JavaScript, Python CGI, ASP.NET, PHP

Contact Methods

  • MSN
    dug@douglasmcgregor.co.uk
  • Website URL
    http://www.douglasmcgregor.co.uk
  • ICQ
    0
  1. Dug

    File Search Problem

    Hi there, I've written a script to search files in a given directory using file_get_contents. The problem is that the script outputs PHP of the search results in the search excerpt which in my mind would be a security risk. Posted my code below. $dir = "C:/inetpub/wwwroot/FortissimoMediaPHP/"; // get all files with .php extension $files = glob($dir . "*.php"); foreach($files as $file) { if (strpos(file_get_contents($file), $_POST["Search"])) { $FileName = str_replace("C:/inetpub/wwwroot/FortissimoMediaPHP/", "", $file); echo "<a href='" . $FileName . "'>$FileName</a><br />"; $html = strip_tags(file_get_contents($file)); preg_match('/' . $_POST["Search"] . '/', $html, $matches); //$inner_array = $matches[0][0]; $f = file($FileName); $key = $_POST["Search"]; $found = false; foreach ($f as $lineNumber => $line) { if (strpos($line, $key) !== false) { $found = true; $lineNumber++; break; } } if ($found) { echo "Found at line $lineNumber"; echo strip_tags($line); } else { "<p>Sorry, the word" . $_POST["Search"] . "was not found.</p>"; } print "<hr />"; } } I'm using PHP 5.2.17 and IIS 7.5. Would it be best to make an array of forbidden words and do something appropriate if it finds the words? It's just things like database connection information that would be vulnerable. Or would it be better to use a different approach? Thanks Douglas
  2. Hi there,I'm very new to the world of graphic design and all that.Most tutorials I've come across deal with lower screen resolutions than my computer uses (as stated in the title), so I was wondering what the best practices are for dealing with screen sizes like I have? I've tried backgrounds in Photoshop 1 pixels x 1 pixels, but it's really small to see so I can't do any proper work with it. Would another option be to create a background for every screen resolution out there and use JavaScript to detect the user's screen size?ThanksDouglas
  3. Dug

    Image Snipping

    Hi there,This question probably has a very simple answer, but I'm not a graphic designer.Is it possible to snip off a small bit of an image, say a sandy beach, and make it into a website background that doesn't look blurred? Windows 7 has a snipping tool, which I've been using, but I just don't understand how to crop it.ThanksDouglas
  4. Hi there, Ok I'm rather stumped with this one so I'm having to ask. I have this code that superwraps the main body content into a div of a specific width, and I want to have a left column and a right column, and have it so that the background colour of the superwrap div goes behind the left column and right column as well. It's refusing to budge with everything I try. My code: /* CSS Document */html, body {height: auto;margin-top: 0;margin-bottom: 0;}body { background-image: url("../images/beach_water05.jpg"); color: #ffffff; letter-spacing: 3px; font-size:small; height: 100%;}p {padding-left: 20px; width: 698px; height: 0px;}h1, h2, h3, h4, h5, h6 {padding-left: 20px;}A{ COLOR: #4444cc; TEXT-DECORATION: underline;}A:hover{ background-color: #336666; color: #ffffff;}#footer{ text-align:center; position:absolute; margin-left:-321px; left:50%; bottom:5px; width:780px; min-width:640px; height:50px; font-size:1em; z-index:5; font-weight:bold;} #superwrap { min-height:100%; width:780px; background-color: #ffc; margin: 0 auto; height: 100%;}#leftcolumn {float:left;width:563px;margin:0;padding:0;min-height: 100%;}#rightcolumn {float:right;width:193px;margin:0;padding:0;}* html #leftcolumn, #rightcolumn {}#mainwrap {min-height:100%;background-color:#ffc;}#container {min-height:100%;width:770px;margin: 0 auto;background-color:#ffc;} Hope someone will be able to help.ThanksDug
  5. Hi all,I've got this really bizarre issue with MySQL. I'm inserting values from a web form, and when I go into the database, all the columns have a value of 0. I don't think there's an issue with my script, since it opens the database and inserts the info as it should. Here's my SQL code that I used to create the table: CREATE TABLE `tblusers` ( `UserID` int(100) NOT NULL auto_increment, `FirstName` varchar(255) NOT NULL default '', `LastName` varchar(255) NOT NULL default '', `Email` varchar(255) NOT NULL default '', `Username` varchar(255) NOT NULL default '', `Password` varchar(255) NOT NULL default '', `Joined` datetime NOT NULL default '0000-00-00 00:00:00', `IP` varchar(255) NOT NULL default '', `Status` varchar(255) NOT NULL default '', PRIMARY KEY (`UserID`)) ENGINE=InnoDB DEFAULT CHARSET=latin1; and it shouldn't be an issue, but here's the insert code: but I've just noticed having exported the SQL code from PhpMyAdmin:INSERT INTO `tblusers` VALUES (1, '0', '0', '0', '0', '0', '0000-00-00 00:00:00', '0', '0'); so I'm really not sure what's going on here, I've never had this problem with MySQL before. Hope someone can help.ThanksDug
  6. Dug

    Query was empty error

    Hi there,I'm doing some projects from the book Sams Teach Yourself PHP, MySQL and Apache, and I simply get this error: here is the SQL queries that I presume it refers to:// add to master_name table $add_master = "insert into master_name values ('', now(), now(), '$_POST[f_name]', '$_POST[l_name]')"; mysql_query($add_master) or die(mysql_error()); // get master_id for use with other tables $master_id = mysql_insert_id(); if (($_POST[address]) || ($_POST[city]) || ($_POST[state]) || ($_POST[zipcode])) { // something relevant, so add to address table $add_address = "insert into address values ('', $master_id, now(), now(), '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zipcode]', '$_POST[add_type]')"; mysql_query($add_address) or die(mysql_error()); } if ($_POST[tel_number]) { // something relevant, so add to fax table $add_fax = "insert into fax values ('', $master_id, now(), now(), '$_POST[tel_number]', '$_POST[tel_type]')"; mysql_query($add_tel) or die(mysql_error()); } if ($_POST[fax_number]) { // something relevant, so add to fax table $add_fax = "insert into fax values ('', $master_id, now(), now(), '$_POST[fax_number]', $_POST[fax_type]')"; mysql_query($add_fax) or die(mysql_error()); } if ($_POST[email]) { // something relevant, so add email table $add_email = "insert into email values ('', $master_id, now(), now(), '$_POST[email]', '$_POST[email_type]')"; mysql_query($add_email) or die (mysql_error()); } if ($_POST[note]) { // something relevant, so add to notes table $add_note = "insert into personal_notes values ('', $master_id, now(), now(), '$_POST[note]')"; mysql_query($add_note) or die(mysql_error()); } I've proofread this about 3 times now and everything looks fine. So wondering if anyone would be able to help me out?ThanksDug
  7. Dug

    Messenger Now Playing Script

    Hi,Thanks for the reply. I've concluded that the code I originally had in this post won't do what I'm looking for... I've found the following code snippet: Imports System.Runtime.InteropServicesPublic Class MSNStatusMessage Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Integer, _ ByVal hWnd2 As Integer, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String) _ As Integer Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal Hwnd As Integer, _ ByVal wMsg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer) _ As Integer Private Const WM_COPYDATA As Short = 74 Private Structure COPYDATASTRUCT Public dwData As Integer Public cbData As Integer Public lpData As Integer End Structure Public Enum EnumCategory As Integer Music = 0 Games = 1 Office = 2 End Enum Public Shared Sub SendStatusMessage(ByVal Enable As Boolean, ByVal Category As EnumCategory, Optional ByVal Message As String = "") Dim Data As COPYDATASTRUCT Dim Buffer As String = "\0" & Category.ToString + "\0" & IIf(Enable, "1", "0") & "\0{0}\0" & Message & "\0\0\0\0" & Chr(0) & "" Dim Handle As Integer = 0 Data.dwData = 1351 Data.lpData = VarPtr(Buffer) Data.cbData = Buffer.Length * 2 Handle = FindWindowEx(0, Handle, "MsnMsgrUIManager", Nothing) If Handle > 0 Then SendMessage(Handle, WM_COPYDATA, 0, VarPtr(Data)) End If End Sub Private Shared Function VarPtr(ByVal e As Object) As Integer Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned) Dim GC2 As Integer = GC.AddrOfPinnedObject.ToInt32 GC.Free() Return GC2 End FunctionEnd Class I've been trying various things with this one as well. How would you go about getting the result of this to appear in an lblMessage.Text string?ThanksDug
  8. Dug

    Messenger Now Playing Script

    Now I'm getting: in reference to:'Displays song info (MSN Messenger)Call SetMusicInfo(My.Settings.CurrentArtistPlaying, "Not Passed", My.Settings.CurrentSongPlaying)
  9. Dug

    Messenger Now Playing Script

    Hi there,Here is my entire script for the ASP.NET page: <script runat="server"> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer Private Const WM_COPYDATA As Short = &H4AS Public Function VarPtr(ByVal o As Object) As Integer Dim GC As System.Runtime.InteropServices.GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(o, System.Runtime.InteropServices.GCHandleType.Pinned) Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32 GC.Free() Return ret End Function Private Structure COPYDATASTRUCT Dim dwData As Integer Dim cbData As Integer Dim lpData As Integer End Structure Public Sub SetMusicInfo(ByRef r_sArtist As String, ByRef r_sAlbum As String, ByRef r_sTitle As String, Optional ByRef r_sWMContentID As String = vbNullString, Optional ByRef r_sFormat As String = "{1} - {0}", Optional ByRef r_bShow As Boolean = True) Dim udtData As COPYDATASTRUCT Dim sBuffer As String Dim hMSGRUI As Integer 'Total length can not be longer then 256 characters! 'Any longer will simply be ignored by Messenger. sBuffer = "Music\" & System.Math.Abs(CInt(r_bShow)) & "\" & r_sFormat & "\" & r_sArtist & "\" & r_sTitle & "\" & r_sAlbum & "\" & r_sWMContentID & "\" & vbNullChar udtData.dwData = &H547S udtData.lpData = VarPtr(sBuffer) udtData.cbData = Len(sBuffer) * 2 Do hMSGRUI = FindWindowEx(0, hMSGRUI, "MsnMsgrUIManager", vbNullString) If (hMSGRUI > 0) Then Call SendMessage(hMSGRUI, WM_COPYDATA, 0, VarPtr(udtData)) End If Loop Until (hMSGRUI = 0) End Sub sub Page_Load(obj as object, e as eventargs) 'Displays song info (MSN Messenger)Call SetMusicInfo(My.Settings.CurrentArtistPlaying, "Not Passed", My.Settings.CurrentSongPlaying)'Clear song infoCall SetMusicInfo("", "", "", , , False) lblMessage.Text = SetMusicInfo end sub </script> After looking over this again, it seems like this script may just send info to Messenger to update the status or something like that. A bit confused here!Dug
  10. Hi there,I have this code that in theory should grab and display the currently playing song from Windows Live Messenger: Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer Public Function VarPtr(ByVal o As Object) As Integer Dim GC As System.Runtime.InteropServices.GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(o, System.Runtime.InteropServices.GCHandleType.Pinned) Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32 GC.Free() Return ret End Function Private Structure COPYDATASTRUCT Dim dwData As Integer Dim cbData As Integer Dim lpData As Integer End Structure Private Const WM_COPYDATA As Short = &H4AS Public Sub SetMusicInfo(ByRef r_sArtist As String, ByRef r_sAlbum As String, ByRef r_sTitle As String, Optional ByRef r_sWMContentID As String = vbNullString, Optional ByRef r_sFormat As String = "{1} - {0}", Optional ByRef r_bShow As Boolean = True) Dim udtData As COPYDATASTRUCT Dim sBuffer As String Dim hMSGRUI As Integer 'Total length can not be longer then 256 characters! 'Any longer will simply be ignored by Messenger. sBuffer = "\0Music\0" & System.Math.Abs(CInt(r_bShow)) & "\0" & r_sFormat & "\0" & r_sArtist & "\0" & r_sTitle & "\0" & r_sAlbum & "\0" & r_sWMContentID & "\0" & vbNullChar udtData.dwData = &H547S udtData.lpData = VarPtr(sBuffer) udtData.cbData = Len(sBuffer) * 2 Do hMSGRUI = FindWindowEx(0, hMSGRUI, "MsnMsgrUIManager", vbNullString) If (hMSGRUI > 0) Then Call SendMessage(hMSGRUI, WM_COPYDATA, 0, VarPtr(udtData)) End If Loop Until (hMSGRUI = 0) End Sub and then to change or clear whatever is being sent to Messenger: 'Displays song info Call SetMusicInfo("Artist", "Album", "Song") 'Clear song info Call SetMusicInfo("", "", "", , , False) What I want to do is display the currently playing song on Messenger in the Page_Load bit of an ASP.NET page. I've tried lblMessage.Text = SetMusicInfo, however I keep getting the error: It works fine without the lblMessage.Text bit, it just doesn't display anything. Any help would be appreciated.CheersDug
  11. Dug

    SQL Error

    Actually never mind, I've sorted it.
  12. Dug

    SQL Error

    Hi all,Ok, I've just got the usual error ....... I've just written a blog script for my site which this database uses, and while I was developing it locally, it worked a treat, but when I uploaded it to my remote server I got this error, and yet it inserts the data fine, and the table columns are exactly the same on both my local and remote server. The code for my insert statement is:strSQL = "INSERT INTO tblcomments (" & _ "BlogID, CommentName, Email, Comment, Added, IP) VALUES (" & _ "'" & Request.QueryString("BlogID") & "'," & _ "'" & tbName.Text & "'," & _ "'" & tbEmail.Text & "'," & _ "'" & RTESafe(request.form("rte1")) & "'," & _ "'" & DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss") & "'," & _ "'" & Request.ServerVariables("REMOTE_ADDR") & "')" I can't see anything wrong with this code, so maybe a fresh pair of eyes would be able to help.CheersDug
  13. Dug

    ASP Repeater Problem

    Hi all,Ok I've written a script for a blog for my site, but I'm wondering if there is a way in the Repeater body bit to display the Container.DataItem depending if there's a value in the database field? If that makes sense....Here is my code: <script runat="server"> Sub Page_Load(obj as object, e as eventargs) dim objConn as new OdbcConnection _ (ConfigurationSettings.AppSettings("LocalBlog")) dim objCmdA as new OdbcDataAdapter _ ("SELECT * FROM tblblog", objConn) dim objCmdB as new OdbcDataAdapter _ ("SELECT * FROM tblcomments", objConn) dim objCmdC as new OdbcDataAdapter _ ("SELECT * FROM tblblog LEFT JOIN tblcomments ON tblblog.BlogID = tblcomments.BlogID", objConn) 'check comments to see if data exists dim ds2 as DataSet = new DataSet() objCmdB.Fill(ds2, "tblcomments") If ds2.Tables("tblcomments").Rows.Count = 0 Then ds2.Clear() 'we don't have any comments, so clear the dataset and display the blog dim ds1 as DataSet = new DataSet() objCmdA.Fill(ds1, "tblblog") 'bind tblblog to server control Repeater1.DataSource = ds1.Tables("tblblog"). _ DefaultView DataBind() Else ' - we have data in both tblblog and tblcomments dim ds3 as DataSet = new DataSet() objCmdC.Fill(ds3, "tblblog, tblcomments") 'bind tblblog and tblcomments to server control Repeater1.DataSource = ds3.Tables("tblblog, tblcomments"). _ DefaultView DataBind() End If End Sub </script><asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <h3><%# Container.DataItem("Title") %></h3> <%# Container.DataItem("Blog") %> <p><a href="Blog/AddComment.aspx?BlogID=<%# Container.DataItem("BlogID") %>">Add Comment</a></p> </ItemTemplate></asp:Repeater> So for example, if there are no comments, the code should be as above, and if there are: <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <h3><%# Container.DataItem("Title") %></h3> <%# Container.DataItem("Blog") %> <%# Container.DataItem("Comment") %> <p><a href="Blog/AddComment.aspx?BlogID=<%# Container.DataItem("BlogID") %>">Add Comment</a></p> </ItemTemplate></asp:Repeater> When I get this working I'll be a very happy bunny!!CheersDug
  14. Sorry I've taken ages to reply.............Ok, progress. I've decided to do my site in ASP.NET now. I've got the blog working - it's displaying the correct comments with the correct post, however it keeps on posting the blog again with the next comment, instead of having the comments all appearing under one blog. Here is my code: <script runat="server"> Sub Page_Load(obj as object, e as eventargs) dim objConn as new OdbcConnection _ (ConfigurationSettings.AppSettings("RemoteBlog")) dim objCmd as OdbcCommand = new OdbcCommand _ ("SELECT * FROM tblblog LEFT JOIN tblcomments ON tblblog.Title=tblcomments.CommentTitle", objConn) dim objReader as OdbcDataReader try objCmd.Connection.Open() objReader = objCmd.ExecuteReader() catch ex as OdbcException lblMessage.Text = ex.Message end try DataGrid1.DataSource = objReader DataGrid1.DataBind() objCmd.Connection.Close() End Sub</script> I'm very nearly there, so just got to get this sorted. Oh, the link to the page I'm doing this on is:BlogCheersDug
  15. Dug

    W3C Validator 500 error

    Phew, thanks for that guys, that's eased my worries a bit!
×
×
  • Create New...