Jump to content

sorn53

Members
  • Posts

    13
  • Joined

  • Last visited

sorn53's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I meant how can i foreach for all the (string)$xml->Device["publicAddress"] foreach ($xml->Device["publicAddress"] as $value) { echo "Public Address: $value <br>"; } Yes im not a expert or even a notice but im trying to learn,
  2. Thank you for your reply, how would i use to show the values of each string ? (string)$xml->Device["publicAddress"] (string)$xml->Device["clientIdentifier"] Both are date stamps i guess i can use date to convert to more readable format. [createdAt] => 1447797662 [lastSeenAt] => 1447797662
  3. <?php $xml = @simplexml_load_file("device.xml/"); echo '<pre>'; print_r($xml); echo '</pre>' <? The above gives, SimpleXMLElement Object ( [@attributes] => Array ( [publicAddress] => 127.0.0.1 ) [Device] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [name] => (Firefox) [publicAddress] => 1.1.1.1 [product] => =Web [productVersion] => 2.0 [platform] => Firefox [platformVersion] => 40.0 [device] => Linux [model] => [vendor] => [provides] => [clientIdentifier] => fdrk1q [version] => 2.4 [id] => 3950 [token] => pqAGXG [createdAt] => 1447 [lastSeenAt] => 14477 [screenResolution] => [screenDensity] => ) [0] => ) How would i create a php page to show the following from the xml content above. Public IP: 1.1.1.1 ClientIdentifier: fdrk1q Created : 1447797662 <-- convert this to readable date also Thanks in advance.....
  4. Thank you very much for all your help lads. I managed to get it working doing the following $expire_hour = date('H',strtotime($expiredate)); $expire = date('Y-m-d H:i:s', strtotime("$expiredate")); $expire_time = time($expire); if (time() > $expire_time) { continue; } if (!empty($hours_exp)) { if ((time() + 3600 * $hours_exp) >= $expire_time) { $hours = date('H',strtotime($expiredate)); regards
  5. A non well formed numeric value encountered with the 2 lines below. $expire_time = mktime($expire); Undefined variable: hours $expires = $hours . " hours!";
  6. Thank you for your suggestion, ill give yours a try but i think i might have solved that part now using the code $expire_hour = date('H',strtotime($expiredate)); $expire = date('d-m-y H:i',strtotime($expiredate)); $expire_time = mktime($expire); Unfortunately im now getting PHP Notice: A non well formed numeric value encountered on line 630 which seems to be the line below causing the error. $expire_time = mktime($expire); No i didnt write the code i used to employ a coder that unfortanately never really is around anymore, i know how to echo statments and variables etc but doing so within a function is quite new to me . I wasnt asking for the exact code on how to complete just some pointers. This is what i have done, the code is working now, im having a issue with another variable $expires = $hours . " hours!"; $expire_hour = date('H',strtotime($expiredate)); $expire = date('d-m-y H:i',strtotime($expiredate)); $expire_time = mktime($expire);
  7. I tried adding echo to each part but nothing was showing im very new to php sorry can you take a look please
  8. $expiredate = "06-09-2015 12:00"; the expire date is taken from the database which includes the 06-09-2015 - 12:00
  9. im unsure as to what you suggested thats why i posted the full code, can you hightlight the parts i should change please
  10. This is the full code Functions.php <?php function send_emails($to = "") { require ("config.php"); $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or sqlerror(); mysql_select_db($dbname, $conn); $sql = mysql_query("SELECT email_msg,emailfrom,subject,hours_exp from settings WHERE id = '1'"); $row = mysql_fetch_row($sql); $email_msg_original = $row[0]; $emailfrom = $row[1]; $subject = $row[2]; $hours_exp = $row[3]; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Alert <' . $emailfrom . '>' . "\r\n"; $headers .= 'Reply-To: Reply <' . $emailfrom . '>' . "\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; if (!empty($to)) { mail($to, $subject, $email_msg_original, $headers); } else { $sql = mysql_query("SELECT * FROM dbb where email_send = 0 AND `usergroup` = '**Tester**'"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $displayname = trim($row['name']); $email = $row['email']; $expiredate = trim($row['expiredate']); $startdate = trim($row['startdate']); $email_msg = @str_replace("{username}", $displayname, $email_msg_original); $email_msg = @str_replace("{startdate}", $startdate, $email_msg); $email_msg = @str_replace("{expiredate}", $expiredate, $email_msg); $expire = preg_replace('/-|:/', null, $expiredate); $expire_hour = preg_replace('/-|:/', null, $expire[3]); $expire_time = mktime($expire_hour[0], $expire_hour[1], 0, $expire[1], $expire[0], $expire[2]); if (time() > $expire_time) { continue; } if (!empty($hours_exp)) { if ((time() + 3600 * $hours_exp) >= $expire_time) { $expires = $hours . " hours!"; $email_msg = @str_replace("{expires}", $expires, $email_msg); mysql_query("UPDATE dbb set `email_send` = '1' where id = '" . $id . "'"); mail($email, $subject, $email_msg, $headers); } } } } } ?> cronjob.php <?php chdir("/var/www/web/"); require ("./includes/functions.php"); send_emails(); ?>
  11. What do you mean ? Oh emails are not being sent anymore i believe its something to do with the mktime part $expire = preg_replace('/-|:/', null, $expiredate); $expire_hour = preg_replace('/-|:/', null, $expire[3]); $expire_time = mktime($expire_hour[0], $expire_hour[1], 0, $expire[1], $expire[0], $expire[2]); expiry dates are grabbed via mysql db, checked & when 12 hours before current date and time it sends a email out normally
  12. Im very new at learning php, hope to learn some / allot whilst im here Thanks in advance for any help provided by the users of this forum regards
  13. Can some one please explain why the below code no longer works, it used to work fine untill i updated php on my server. $expiredate = "06-09-2015-12:00"; $expire = preg_replace('/-|:/', null, $expiredate); $expire_hour = preg_replace('/-|:/', null, $expire[3]); $expire_time = mktime($expire_hour[0], $expire_hour[1], 0, $expire[1], $expire[0], $expire[2]); if (time() > $expire_time) { continue; } if (!empty($hours_exp)) { if ((time() + 3600 * $hours_exp) >= $expire_time) { $expires = $hours . " hours!"; $email_msg = @str_replace("{expires}", $expires, $email_msg); mysql_query("UPDATE cmum_udb set `email_send` = '1' where id = '" . $id . "'"); mail($email, $subject, $email_msg, $headers); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.