Results 1 to 14 of 14

Thread: Setting a users vacation message through the api

  1. #1
    Join Date
    Apr 2006
    Posts
    17

    Setting a users vacation message through the api

    I've been busy working on this today and figured that others may benefit from what I've done.
    I've written some php using l0rdphi1's php class (nice one btw!!) to log in an email user and allow them to set their own vacation message.
    It's still a work in progress and needs the modification / delete sections added, but you'll get the jist.

    I hope this helps!!

    The HTML Logon Form:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Verify Users Email Login</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body><center><br><br>
    <form action="login.php" method="post">
    <table width="70%" border="0">
    <tr>
    <td width="21%">Full Email Address:</td>
    <td width="54%"><input name="email" type="text" size="64" maxlength="64"></td>
    <td width="25%">(e.g. user@domain.com) </td>
    </tr>
    <tr>
    <td>Password: </td>
    <td><input type="password" name="passwd"></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input name="submit" type="submit" value="Login"></td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>

  2. #2
    Join Date
    Apr 2006
    Posts
    17
    The login.php:

    <?php

    session_start();

    // Setting variables for this script only
    $email = $_POST["email"];
    $passwd = $_POST["passwd"];

    // Beginning API call
    include 'httpsocket.php';

    $sock = new HTTPSocket;

    $sock->connect('ssl://domain.com',2222);
    $sock->set_login('username','password');

    $sock->set_method('POST');

    // Authenticate User
    $sock->query('/CMD_API_EMAIL_AUTH',

    array(

    'email' => $email,
    'passwd' => $passwd,

    ));

    $result = $sock->fetch_parsed_body();

    if ($result["error"] == 1) {
    echo "<br><br><center>";
    echo "Invalid Email Address or Password<br><br>";
    echo "Click <a href=\"login.html\">here </a>to return to the login screen<br></center>";
    die();

    } else {

    // Setting Session wide variables for further scripts
    $_SESSION['email'] = $_POST['email'];

    $domain = "@niandj.com";
    $_SESSION['user'] = str_replace($domain, "", $_SESSION['email']);

    }

    // Checking to see if a Vacation message already exists
    $sock = new HTTPSocket;

    $sock->connect('ssl://domain.com',2222);
    $sock->set_login('username','password');

    $sock->set_method('POST');


    $sock->query('/CMD_API_EMAIL_VACATION_MODIFY',

    array(

    'domain' => 'domain.com',
    'user' => $_SESSION['user'],
    ));

    $result = $sock->fetch_parsed_body();

    // If the vacation text is returned as null then we prompt the user to create a new message using the form displayed
    if ($result["text"] == "") {

    echo "<center><br><br>You do not have a Vacation Message, please enter your new message below<br><br><br></center>";

    // Otherwise they are prompted to modify their existing message
    } else {

    echo "<center><br><br>Click <a href=\"modifyedit.php\">here</a> to modify your existing Vacation Message</center>";
    die();

    }

    ?>

    <html>
    <HEAD>
    <title>Vacation Entry</title>
    </HEAD>
    <body>
    <br><br>
    <table class=list cellpadding=3 cellspacing=1>
    <form name=info action="submitvacation.php" method="post">
    <tr><td class=list>Email Account: </td><td><?PHP print_r($email); ?></td></tr>
    <tr><td class=list>Vacation Message:</td><td class=list align=center><textarea rows=15 cols=60 name=text></textarea></td></tr>
    <tr><td class=list>Vacation Start: </td><td class=list>
    <select class=selectclass name=starttime>
    <option value="morning">Morning</option >
    <option value="afternoon">Afternoon</option >
    <option value="evening">Evening</option >
    </select >
    of
    <select class=selectclass name=startmonth>
    <option selected value="01">Jan</option >
    <option value="02">Feb</option >
    <option value="03">Mar</option >
    <option value="04">Apr</option >
    <option value="05">May</option >
    <option value="06">Jun</option >
    <option value="07">Jul</option >
    <option value="08">Aug</option >
    <option value="09">Sep</option >
    <option value="10">Oct</option >
    <option value="11">Nov</option >
    <option value="12">Dec</option >
    </select >
    <select class=selectclass name=startday>
    <option selected value="01">01</option >
    <option value="02">02</option >
    <option value="03">03</option >
    <option value="04">04</option >
    <option value="05">05</option >
    <option value="06">06</option >
    <option value="07">07</option >
    <option value="08">08</option >
    <option value="09">09</option >
    <option value="10">10</option >
    <option value="11">11</option >
    <option value="12">12</option >
    <option value="13">13</option >
    <option value="14">14</option >
    <option value="15">15</option >
    <option value="16">16</option >
    <option value="17">17</option >
    <option value="18">18</option >
    <option value="19">19</option >
    <option value="20">20</option >
    <option value="21">21</option >
    <option value="22">22</option >
    <option value="23">23</option >
    <option value="24">24</option >
    <option value="25">25</option >
    <option value="26">26</option >
    <option value="27">27</option >
    <option value="28">28</option >
    <option value="29">29</option >
    <option value="30">30</option >
    <option value="31">31</option >
    </select >
    <select class=selectclass name=startyear>
    <option value="2002">2002</option >
    <option value="2003">2003</option >
    <option value="2004">2004</option >
    <option value="2005">2005</option >
    <option selected value="2006">2006</option >
    <option value="2007">2007</option >
    <option value="2008">2008</option >
    <option value="2009">2009</option >
    <option value="2010">2010</option >
    <option value="2011">2011</option >
    <option value="2012">2012</option >
    <option value="2013">2013</option >
    <option value="2014">2014</option >
    <option value="2015">2015</option >
    <option value="2016">2016</option >
    <option value="2017">2017</option >
    <option value="2018">2018</option >
    <option value="2019">2019</option >
    <option value="2020">2020</option >
    <option value="2021">2021</option >
    <option value="2022">2022</option >
    <option value="2023">2023</option >
    <option value="2024">2024</option >
    <option value="2025">2025</option >
    <option value="2026">2026</option >
    <option value="2027">2027</option >
    <option value="2028">2028</option >
    <option value="2029">2029</option >
    </select >
    </td></tr>
    <tr><td class=list>Vacation End:</td><td class=list>
    <select class=selectclass name=endtime>
    <option value="morning">Morning</option >
    <option selected value="afternoon">Afternoon</option >
    <option value="evening">Evening</option >
    </select >
    of
    <select class=selectclass name=endmonth>
    <option selected value="01">Jan</option >
    <option value="02">Feb</option >
    <option value="03">Mar</option >
    <option value="04">Apr</option >
    <option value="05">May</option >
    <option value="06">Jun</option >
    <option value="07">Jul</option >
    <option value="08">Aug</option >
    <option value="09">Sep</option >
    <option value="10">Oct</option >
    <option value="11">Nov</option >
    <option value="12">Dec</option >
    </select >
    <select class=selectclass name=endday>
    <option selected value="01">01</option >
    <option value="02">02</option >
    <option value="03">03</option >
    <option value="04">04</option >
    <option value="05">05</option >
    <option value="06">06</option >
    <option value="07">07</option >
    <option value="08">08</option >
    <option value="09">09</option >
    <option value="10">10</option >
    <option value="11">11</option >
    <option value="12">12</option >
    <option value="13">13</option >
    <option value="14">14</option >
    <option value="15">15</option >
    <option value="16">16</option >
    <option value="17">17</option >
    <option value="18">18</option >
    <option value="19">19</option >
    <option value="20">20</option >
    <option value="21">21</option >
    <option value="22">22</option >
    <option value="23">23</option >
    <option value="24">24</option >
    <option value="25">25</option >
    <option value="26">26</option >
    <option value="27">27</option >
    <option value="28">28</option >
    <option value="29">29</option >
    <option value="30">30</option >
    <option value="31">31</option >
    </select >
    <select class=selectclass name=endyear>
    <option value="2002">2002</option >
    <option value="2003">2003</option >
    <option value="2004">2004</option >
    <option value="2005">2005</option >
    <option selected value="2006">2006</option >
    <option value="2007">2007</option >
    <option value="2008">2008</option >
    <option value="2009">2009</option >
    <option value="2010">2010</option >
    <option value="2011">2011</option >
    <option value="2012">2012</option >
    <option value="2013">2013</option >
    <option value="2014">2014</option >
    <option value="2015">2015</option >
    <option value="2016">2016</option >
    <option value="2017">2017</option >
    <option value="2018">2018</option >
    <option value="2019">2019</option >
    <option value="2020">2020</option >
    <option value="2021">2021</option >
    <option value="2022">2022</option >
    <option value="2023">2023</option >
    <option value="2024">2024</option >
    <option value="2025">2025</option >
    <option value="2026">2026</option >
    <option value="2027">2027</option >
    <option value="2028">2028</option >
    <option value="2029">2029</option >
    </select ></td></tr>

    <tr><td class=listtitle colspan=3 align=right>

    <input type=submit name=create value="Create">
    </td></tr>
    </form>
    </table>
    </body>
    </html>

  3. #3
    Join Date
    Apr 2006
    Posts
    17
    and the submitvacation.php:

    <?php

    session_start();

    if ($result["error"] == 1) {
    die("You are not authorized, please login first");

    } else {

    // Setting Session Wide Variables
    $_SESSION['text'] = stripslashes($_POST['text']);
    $_SESSION['starttime'] = $_POST['starttime'];
    $_SESSION['startmonth'] = $_POST['startmonth'];
    $_SESSION['startday'] = $_POST['startday'];
    $_SESSION['startyear'] = $_POST['startyear'];
    $_SESSION['endtime'] = $_POST['endtime'];
    $_SESSION['endmonth'] = $_POST['endmonth'];
    $_SESSION['endday'] = $_POST['endday'];
    $_SESSION['endyear'] = $_POST['endyear'];

    // Calling the DA API
    include 'httpsocket.php';

    $sock = new HTTPSocket;

    $sock->connect('ssl://domain.com',2222);
    $sock->set_login('username','password');

    $sock->set_method('POST');

    $sock->query('/CMD_API_EMAIL_VACATION',

    array(

    'domain' => 'domain.com',
    'action' => 'create',
    'user' => $_SESSION['user'],
    'text' => $_SESSION['text'],
    'starttime' => $_SESSION['starttime'],
    'startmonth' => $_SESSION['startmonth'],
    'startday' => $_SESSION['startday'],
    'startyear' => $_SESSION['startyear'],
    'endtime' => $_SESSION['endtime'],
    'endmonth' => $_SESSION['endmonth'],
    'endday' => $_SESSION['endday'],
    'endyear' => $_SESSION['endyear'],
    'create' => 'Create'
    ));

    $result = $sock->fetch_parsed_body();

    if ($result["details"] == "A message for that user already exists") {

    echo "Submit Failed for: ";
    print_r($_SESSION['user']);
    echo "<br>";
    echo "email: ";
    print_r($email);
    echo "<br>";
    echo "Vacation Message: ";
    print_r($text);
    echo "<br><br>";
    echo "A message for that user already exists";
    echo "<br><br>";
    echo "Click <a href=\"modifyoverwrite.php\">here</a> to overwrite your old message or click <a href=\"modifyedit.php\">here</a> to edit your old message.";


    } else {

    print_r($result);

    }

    }

    ?>

  4. #4
    Join Date
    Apr 2006
    Posts
    17
    I'm new to php, but this code is working

    Please let me know if I'm going about it totally wrong!

    Cheers!!

  5. #5
    Join Date
    Jan 2005
    Posts
    44
    Hi natterjacks,

    Any chance of seing the modify*.php files too? Thanks!

  6. #6
    Join Date
    Apr 2006
    Posts
    17
    Hi,

    Since then I've changed the code quite a bit to tidy things up. The text is all in Dutch now, which probably won't help you much.

    Give me a couple of days and I'll run through the files, translate it back to english and put it all in a zip file.

    Cheers,

    Nathan

  7. #7
    Join Date
    Jan 2006
    Location
    Oakland, CA
    Posts
    8
    Any chance you're still willing to share the work you've done? I tried working with the information you shared, but haven't ever hacked on php code before and haven't been able to get things working yet.

  8. #8
    Join Date
    Apr 2006
    Posts
    17
    here's the zip with all files included.

    hth,

    Nathan
    Attached Files Attached Files

  9. #9
    Join Date
    Jan 2006
    Location
    Oakland, CA
    Posts
    8
    Thank you! I've got it working now!

  10. #10
    Join Date
    Jun 2004
    Posts
    225
    mine is not working. when we submit, it says the vacation message was entered and when we click the link to go back and look at the message, it is not there and the system can't find it.
    We log into DA and it is not in there either.

    Any suggestions?
    Kind Regards,
    John
    One of the two dads

  11. #11
    Join Date
    Jan 2006
    Location
    Oakland, CA
    Posts
    8
    Have you checked that all your files are owner.group apache.apache? And have you edited vacation.php to include the domain for which you are trying to set things up?

  12. #12
    Join Date
    Jun 2004
    Posts
    225
    no. instructions did not indicate owner/group had to be changed.

    I do not have the access to change the owner/group anyway.
    If I am not able to change the owner/group, will I not be able to run this on my client site? This has to be installed on the client site...
    Last edited by jechilt; 09-08-2007 at 06:48 AM.
    Kind Regards,
    John
    One of the two dads

  13. #13
    Hello,

    I've created an Email Level plugin:
    http://www.directadmin.com/forum/showthread.php?t=22715

    John

  14. #14
    Join Date
    Jun 2003
    Location
    California
    Posts
    26,123
    Quote Originally Posted by DirectAdmin Support View Post
    Hooray!

    Thanks, John.

    Jeff
    +1 951 643-5345
    Third-Party DirectAdmin administration and support
    Dedicated Servers, Dedicated Reseller Accounts
    NoBaloney Internet Services div. Qnito Incorporated
    848 North Rainbow Blvd., Suite #3789
    Las Vegas, NV 89107-1103

Similar Threads

  1. No vacation message
    By bernikm in forum DirectAdmin General Discussion
    Replies: 1
    Last Post: 11-07-2012, 01:49 AM
  2. Bug vacation message
    By pppplus in forum E-Mail
    Replies: 7
    Last Post: 10-11-2012, 02:21 PM
  3. Vacation Message ?
    By nijssen in forum General Technical Discussion & Troubleshooting
    Replies: 1
    Last Post: 06-28-2012, 06:31 AM
  4. Replies: 3
    Last Post: 10-28-2009, 10:01 AM
  5. vacation message
    By Lem0nHead in forum Feedback & Feature Requests
    Replies: 3
    Last Post: 11-30-2007, 01:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •