jay.barnes 4

Sorry....going into a little more detail....

Both Google Calendar and Mozilla Lightning (a calendar extension for their mail application, Thunderbird) are capable of adding calendars by URL- you just point the application to your ICS file, and it adds them automatically. This should be separate from "importing" an ICS file in that it looks to the file on the server to synchronize and get events.

I'm finding that adding the calendar is not a problem, it's getting either application to add the calendar in anything outside of "read only" mode that's throwing me off.

jay.barnes 4 Light Poster

Hi, all!

This seemed like the best place to pose my question, as there doesn't seem to be any forum specifically targeting ICS files...

I have a web server, where I have a script that generates ICS files. I can successfully import the ICS files into Google Calendar (browser-based) and Mozilla Lightning (so far), and view events. However, I can't seem to edit them in either place. Mozilla loads the ICS file in "read only" mode, and Google lists the calendar as an "other calendar", which I can't write to.

I have the permissions for the ICS file set to '777', and its parent folders all set to '777' up to the rootfolder of the website, which is set to '644'.

Any thoughts? Suggestions? Need for further details?

Thanks,
-Jay

jay.barnes 4

That was what did it. Thank you for your assistance!

jay.barnes 4

Getting closer....it should be returning:

5
6

Now, instead of looping the groupID of the first record over and over again, it's now skipping the first record, and returning only the groupID of the second record:

6

jay.barnes 4

A good suggestion, but now it just walks through all the fields of the first record returned, along with the error "Warning: Illegal string offset 'groupID' in /home/roadtostage/roadtostage.com/includes/groupSummary.php on line 35" after each echo.

The actual return was:

Warning: Illegal string offset 'groupID' in /home/roadtostage/roadtostage.com/includes/groupSummary.php on line 35
4

Warning: Illegal string offset 'groupID' in /home/roadtostage/roadtostage.com/includes/groupSummary.php on line 35
1

Warning: Illegal string offset 'groupID' in /home/roadtostage/roadtostage.com/includes/groupSummary.php on line 35
5

Warning: Illegal string offset 'groupID' in /home/roadtostage/roadtostage.com/includes/groupSummary.php on line 35
D

Warning: Illegal string offset 'groupID' in /home/roadtostage/roadtostage.com/includes/groupSummary.php on line 35
P

on the other questions, this is part of a class.

This code in this class should be okay, because it's not reliant upon any user input (the values in the class all come from session data that's already determined, with no input fromt he user...

...unless there's an aspect of SQL injection attacks that I didn't take under consideration?

jay.barnes 4 Light Poster

Hey, all

I've got this script that runs a simple 'select' query:

function set_selectAssoc($usernumber) {
        $this->execute = $this->connection->query("SELECT * FROM `link-UsersToGroups` WHERE userID = ".$usernumber);
        $this->num_rows = $this->execute->num_rows;
        $this->results = $this->execute->fetch_assoc();

        if ($this->num_rows == 0) {
            $this->response_code = 2;
            $this->response_msg .= "You don't currently seem to belong to any groups yet.  Would you like to create one?";
        }
        else {
            $this->response_code = 0;
            echo "Number of rows found: ".$this->num_rows."<BR>";
            do {
                echo $this->row["groupID"]."<BR>";
            } while ($this->row = $this->results);
        }
    }

the first echo statement (echo "Number of rows found: ".$this->num_rows."<BR>";) returns correctly (two rows found), but, when it comes to the 'do...while' block that's supposed to walk through the results, it just echos the groupID of the first row in an endless loop.

Any suggestions?

Thank you!

-Jay

Thanks!

jay.barnes 4

I ended up using it in 'dashboard.php', but it worked perfectly. Thank you for your help!

jay.barnes 4 Light Poster

Hi, all

I have a web page that breaks down to several divs, two of them containing iframes (one for content, one for a menu):

<HEAD>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="styles/default.css?ver=33">
</HEAD>
<BODY>
<div id="wrapper">
    <div id="header">Welcome to my website</div>
    <div id="menu"><iframe name="frame-menu" id="frame-menu" src="menu.php" frameborder="0" height="30"></iframe></div>
    <div id="main"><iframe name="frame-main" id="frame-main" src="login.php" frameborder="0" width="878" height="700"></iframe></div>
    <div id="footer"><A HREF="about.php" TARGET="frame-main">About Us</A> - Contact</div>
    <div id="bottom">&copy;2015</div>
</div>
</BODY>

After the user logs in via the form on the 'login.php' page, it runs through a PHP script that registers their login, and takes them to an account summary page (dashboard.php). I'm looking to use a JQuery script in dashboard.php to reload the menu iframe, so that I can run the PHP script that changes the "Log In" link on the menu to a "Log Out" link.

I have tried altering the solution suggested in https://www.daniweb.com/web-development/php/threads/319050/reload-the-iframe-src , but I can't figure out how to alter it to fit my situation.

Thanks!

jay.barnes 4 Light Poster

Hi, all

I'm working on a website that is comprised of two iframes within several nested divs ( the frames named "frame-menu" and "frame-main"). Displaying as such:

<div id="wrapper">
    <div id="header">Header text/image goes here</div>
    <div id="menu"><iframe name="frame-menu" id="frame-menu" src="menu.php" frameborder="0" height="30"></iframe></div>
    <div id="main"><iframe name="frame-main" id="frame-main" src="login.php" frameborder="0" width="878" height="700"></iframe></div>
    <div id="footer"><A HREF="about.php" TARGET="frame-main">About Us</A> - Contact</div>
    <div id="bottom">&copy;2015</div>
</div>

When the user logs on via the 'login.php' form, I'd like to reload the 'menu.php' file in the 'frame-menu' frame, to run the PHP conditionals to change the "log in" link to a "log out" link. However, I can't figure out a way to get the menu.php file to reload.

I've tried adding headers to the code of beginning of the page that loads after the user logs in...

header('Window-target: frame-menu');
header('Location: https://www.website.com/menu.php');

and had no luck.

I know this can be accomplished via Javascript, but I'm rather hesitant to use it, as users can turn it off, and, well, completely screw up my login process...

Does anyone have any suggestions for me on this?

Thank you!

jay.barnes 4

Thanks lps! That took care of it!

I'll get what you're suggesting, diafol - I was a little rushed when I put my post together, so I just had to make sure I included the part where I knew the script was failing.

Thank you both for your help!

jay.barnes 4 Light Poster

What's wrong with this?

$db = new mysqli("DBserver","username","password","database");
if ($db->connect_error) {
    die('Connect Error ('.$db->connect_errno.')'.$db->connect_error);

class registerInvitedUser {
    protected $formdata = array();
    protected $connection;
    protected $execute;
    protected $results;
    protected $response_code = "";
    protected $response_msg = "";

    public function __construct($db)
    {
        $this->connection = $db;
    }

    $this->execute = $this->connection->query("UPDATE `users` SET acctstatus= 'A' WHERE email = '".$formdata["email"]."'");
    $this->results = $this->execute->affected_rows;
    if ($this->results == 1) {
       $echo "user updated!";
       $this->response_code = '0';
       $this->response_msg .= 'Your account has successfully been created!  You may now <A HREF="loginform.php">click here</A> to log in with your username and password';
    }
}

The query executes and successfully updates the database, but the affected_rows conditional isn't getting tripped, and I haven't been able to figure out why.

Thanks for any suggestions you guys might have!

jay.barnes 4

That took care of it!

I'm getting a better grasp of how the mysqli object works, now. It'll take some time to 'master' it, but you've pointed me in the right direction, thank you.

jay.barnes 4

Looks like I may have spoken too soon....

I have tried subbing in your suggestion via copy/paste, and inserting my DB connection credentials, but I'm getting a new error on top of the original one:

Warning: Missing argument 1 for siteConfig::__construct(), called in /home/website/website.com/index.php on line 3 and defined in /home/website/website.com/includes/class_lib.php on line 25

Line 3 of index.php just instantiates the siteConfig object ($siteconfig = new siteconfig();), and line 25 of class_lib.php is

public function __construct($db)

I'm also still getting the error

Fatal error: Call to a member function query() on a non-object in /home/roadtostage/roadtostage.com/includes/class_lib.php on line 30

with line 30 being

$res = $this->db->query($mysqli,"SELECT status FROM `site-config`");

Looking at that line more closely, shouldn't $mysqli be $db? Either way, changing that variable didn't make the error go away. I'm just wondering if that would need to be corrected/changed after I addressd the fatal error.

Either way, thanks!

jay.barnes 4

Thank you for the assistance, diafol!

I still have to read up more on constructors, though (no matter what I've read on them, I still can't seem to grasp the advantage of using them), so I'll just set the value in the method...

Have a great weekend!

jay.barnes 4 Light Poster

Hi all

I'm trying to set my mysqli connection to my database as outlined in http://php.net/manual/en/mysqli.quickstart.connections.php , with one difference - I'm trying to put my connection parameters in an include file outside of my root folder, to try to secure my DB password.

$mysqli = new mysqli("DBServer", "DBUsername", "DBPassword", "DBName");  //set connection params
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: " . $mysqli->connect_error;
    exit();

Now, with my query object, I can confirm that the connection is established, and the connection file is included when I launch my class_lib file, but, when I try to use the connection object, it returns "Call to a member function query() on a non-object in filename on line 21"

The code for my object is as follows:

class siteConfig {
    protected $results = array();
    public function set_siteConfig() {
        $res = $mysqli->query($mysqli,"SELECT status FROM `site-config`");
        $this->results = $res->fetch_assoc();
        $mysqli->close();
    }
    public function get_siteConfig() {
        return $this->results;
        }
}

The error message is telling me that the error is in the line "$res = $mysqli->query($mysqli,"SELECT * FROM site-config");"

How can I correctly implement my database connection, while, at the same time, keeping my database credentials secure?

Thanks for any suggestions you guys might have!

-Jay

jay.barnes 4

Interesting way to look at it- thanks diafol!

I'll run through your suggestions, if only just to at least get an understanding of what's going on in your code (I'm always looking for more efficient ways to accomplish what I'm trying to do).

jay.barnes 4

Success!

I took some of your suggestions, pritaeas, and managed to cobble something together that worked (omitting comments for brevity's sake):

class formValidator {
    var $response_code = 0;
    var $response_msg = "";
    var $pwd = array();

    public function set_user_input($user_input){
        foreach ($user_input as $key => $value){
            if(strpos($key,"p-") !== FALSE) {
                //verify that password and confirm password fields match
                $pwd[] = $value;
            }
            if(strpos($key,"r-") !== FALSE) {
                //Check string length, if 0 then return empty field message
                if (strlen($value) === 0) {
                    $this->response_code = 2;
                    $this->response_msg .= "<LI>Required field, ".$key." is empty!";
                }
            }
            if(strpos($key,"e-") !== FALSE){
                if (is_string($value)&&($value != "")) {
                    $value = str_replace(' ','',$value);
                    $pattern = "/^[a-zA-Z0-9_]+@{1}[a-zA-Z]+\.{1}[a-zA-Z]+/";
                    if (!(preg_match($pattern, $value))) {
                        $this->response_code = 1;
                        $this->response_msg .= "<LI>Entered e-mail address is not valid!";
                    }
                }
            }
        }
        if ($pwd[0] != $pwd[1]) {
            $this->response_code = 1;
            $this->response_msg .= "<LI>Entered passwords do not match!";
        }
    }
    public function get_user_input(){
        $msg_params = array();
        $msg_params["code"] = $this->response_code;
        $msg_params["msg"] = $this->response_msg;
        return $msg_params;
    }
}
class MessageBox {
    var $color = "";
    var $msg = "";
    public function set_message($msg_params) {
        if ($msg_params["code"] == '0') {
            $this->color = "#00FF00";
        }
        elseif ($msg_params["code"] == '1') {
            $this->color = "#FF0000";
        }
        elseif ($msg_params["code"] == '2') {
            $this->color = "#FFFF00";
        }
        $this->msg = $msg_params["msg"];
    }
    public function get_message() {
        return "<div style=\"background-color:".$this->color."\">".$this->msg."</div>";
    }
}

And used as:

if ($_POST["submit"] == "Create Account") {
    $msg = new MessageBox();
    $validator = new formValidator();
    $validator -> set_user_input($_POST);
    $msg_params = $validator->get_user_input();
    $msg -> set_message($msg_params);

}

Thanks again for your assistance!

jay.barnes 4

I think.....maybe? I'll have to play around with it a bit to figure it all out....I'm picking up on OO basics, but sometimes, I have to really turn some ideas over in my head for a while (sometimes a few days) just to wrap my brain around them...it all comes down to being too dumb to know when to quit! :-)

jay.barnes 4

Heh...oddly enough, I've been reading and referring back to that article alongside this discussion thread! :-)

I was hoping that my message class could take two pieces of output from other classes: The error code (0, 1, or 2), and a short message string.

The error code would determine the formatting of the message back to the user (should the text be in red and bold-faced, as a critical error? Or black as simply an informational message?), and the message string, which would be just the content. Every class that would call that message would just need those two elements. I was looking to keep it simple, but versatile...

jay.barnes 4

What was looking to do was essentially ""message" class extends classA, and classB, and classC, and classD,...."

However, the more I look at the proper implementaton of extending classes, I think I'm looking at it the wrong way (from what I see, extending a class is only used to extend and augment the fundamental purpose of the parent class, not to just call some other class and use its properties)...so, it looks like I'm wondering how to "call" properties from many other classes into one class.....does that make more sense?

I want this message class to be a generic, reusable class where I can get output from any other class to bring up a message that I can use anywhere on my site, for any reason...I want it to return error messages back to the user, bring up reminders, notify them of content updates, and almost any other single-instance communication you can think of bringing to a user's attention....

Thanks again for all your suggestions!

jay.barnes 4

Thanks for the replies and suggestions, all - it gives me a lot of food for thought, but it doesn't quite answer my original question. I think I might be able to phrase it better:

Understanding using "extends" creates a parent-to-child "one to one" relationship, how would I go about creating a "many-to-one" relationship between classes or methods?

jay.barnes 4 Light Poster

Hi all,

I've been working with PHP, using procedural methods, for several years now, and have begun to explore the object-oriented side of it. While it didn't take me long to understand the potential advantages that come with working in this manner, I'm still having some trouble wrapping my head around doing the things I used to do procedurally in an object-oriented manner. A lot of the tutorials cover the basic applications of classes, properties, and methods, but I'm having trouble applying them to projects I'm working on.

For instance, I have a form, that I put a class together to validate it:

class formValidator {
    //set your properties for the class
    private var $user_input = array();
    protected var $response_code = 0;
    protected var $response_msg = "";

    public function set_validator($user_input){
        foreach ($user_input as $key => $value){
            //check to see if the field name contains "e-",
            //designating it as a required field
            if(strpos($key,"r-") !== FALSE) {
                //Check string length, if 0 then return empty field message
                if (strlen($value) === 0) {
                    $this->response_code = 1;
                    $this->response_msg = "Required field is empty!";
                }
            }
            //check to see if the field name contains "e-",
            //designating it as an e-mail field
            if(strpos($key,"e-") !== FALSE){
                //Check the datatype to confirm a string has been passed in
                if (is_string($value)&&($value != "")) {
                    //Regular expression pattern.
                    //Pattern breakdown:
                    //** [a-zA-Z0-9_] - any character between a-z, A-Z or 0-9
                    //** + - require one or more of the preceding item.
                    //** @{1} - Simply means 1 '@' symbol required. ...

jay.barnes 4

My apologies for the delayed response, but JorgeM got me going in the right direction, and after a lot of trial and error, I managed to get it to work. Here's what ended up working for me:

Dim path_to_pdf As String
path_to_pdf = Server.MapPath("/path/to/file/filename.pdf")
If System.IO.File.Exists(path_to_pdf) Then
  response.write("<a href='http://server/path/to/file/filename.pdf'>Completed</a>")
End If

Thanks again!
-Jay

jay.barnes 4 Light Poster

Hi, all

I'm working with an aspx file that's supposed to check on a directory (on the same server the file lives on) to see if a file of a particular name exists. Based on its response, it's either supposed to create a link to that file, or, well, do nothing. The code I'm working from is below:

Try
  wc_result = web_client.DownloadData(\\server\dir\subdir\filename.pdf)
  Catch ex As Exception
  If Left(ex.Message, 6) = "THIS FILE EXISTS" Then
    link = "<a target='_blank' href='\\server\dir\subdir\filename.pdf'>Here is the file</a>"
  End If
End Try

Response.write(link)

If I insert a line to echo back the ex.Message, it tells me "The network path was not found". But, we're talking about the same server?!? I dont' think it's a permissions issue, or else it would have explicitly told me so.

I verified that the file does exist, and that the UNC path was accurate.

If I change the "If Left(ex.Message, 6) = "" criteria to "The ne", so it satisfies the boolean, it does create the "Here is the file" link, which does load the PDF, but the ex.Message still says that the network path is not found.

Any suggestions, please?

Thanks!

jay.barnes 4

Ah, that seemed to break the logjam...

I changed removed the 'body' attribute, and added the background color to the 'html' attribute, and found that that, as well, wouldn't take.

It turned out that I had a stray character before my 'html' attribute name. I removed it, and the background image loaded properly.

It looks like it was a combination of the lack of "..\" in the image path, and that stray character throwing off the CSS.

Thank you, hericles and diafol, for your assistance in figuring this out!

jay.barnes 4

You know? I wish I had thought of that, just on principle.

Unfortunately, though, it did not work...

Along that same line, I tried using the absolute path to the JPG, but, no success..

A good suggestion, though- that made total sense to me...

jay.barnes 4

Hi diafol - I'm not using both the inline and the reference to the external file - I was just trying both to see what results I get, and to help identify why the external style doesn't load (my preferred method)

hericles - my CSS is in a 'styles' subdirectory from my root. My PHP files are located in the root directory. At the same time, when I use the reference to the CSS file, the "body" selector without a problem, but it ignores the "html" selector, entirely.

When I'm using the external CSS file, my PHP looks like:

<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="styles/cmhome.css">
<TITLE>CM V2.0</TITLE>
</HEAD>
<BODY>
Words
</BODY>
<HTML>

I'm keeping the file about as simple as I can, just to troubleshoot this CSS issue.

Thanks for your input!

jay.barnes 4 Light Poster

I'm working on implementing CSS on my site, and have a problem with using a background image. When I use the background image inline in the PHP file, as below:

<style>
html{ 
  background: url(images/bgimage.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
body{
  font-family:"Trebuchet MS", Helvetica, sans-serif;
  font-size:16px;
  color:#ffffff;
}
</style>

The background image displays properly. However, when I use a separate CSS file, containing:

html { 
  background: url(images/ralnabg.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
body{
background-color:#0000ff;
font-family:"Trebuchet MS", Helvetica, sans-serif;
font-size:16px;
color:#ffffff;
}

The PHP page ignores the 'html' selector of the code, but does implement the 'body' selector, and I haven't been able to figure out why. I have this problem, regardless of whether I use Internet Explorer, Firefox, or Chrome.

Thanks for any suggestions you may have!

-Jay

jay.barnes 4

Ah, I got it figured out!

It turned out that the instances of "(mysql_query($createadminquery))" found in lines 23, 27, 73 were executing the insert statement three times. Once I corrected the latter two to "if($Result)", that got rid of the extra inserts.

Thank you, again, urtrivedi for being a second pair of eyes on my code!

jay.barnes 4

So, you're saying I should unset '$_SESSION' as well as '$_POST' at line 50 to blow away any session cookies that might be sitting on the server?

Or could the problem be with my own browser cookies?