Jump to content

jasonc

Members
  • Posts

    860
  • Joined

  • Last visited

Posts posted by jasonc

  1. 	$fetch = db_query($mysqli, "SELECT * FROM `info` WHERE `section` = 'openingtimes'");
    	$result = $fetch->fetch_assoc();
    	$openingtimes = $result['content'];
    	$openingtimes = str_replace("\r\n", "
    	<br>
    	", $openingtimes);
    	
    	$fetch = db_query($mysqli, "SELECT * FROM `info` WHERE `section` = 'foodtimes'");
    	$result = $fetch->fetch_assoc();
    	$foodtimes = $result['content'];
    	$foodtimes = str_replace("\r\n", "
    	<br>
    	", $foodtimes);
    	?>
    	<?php
    	echo($openingtimes); ?><br><br><?php
    	echo($foodtimes);?><br><br>

    Instead of accessing the DB twice only access once.

  2. CREATE TABLE `info` ( `id` int(11) NOT NULL, `section` text NOT NULL, `content` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    The table below is what I have setup but having issues accessing the content based on the section needed.

    I have tried...
    $result['sectionname']['content']
    but nothing shows.
    What is the correct way to access each content using the section. without doing it one query for each one.

  3. On 10/7/2021 at 9:00 PM, Barand said:

    Because there is a mix of old (edited) records and new ones, the simplest way to update the DB is with

    INSERT INTO tablename (id, list_order, food, price)
    VALUES ( ?, ?, ?, ?)
    ON DUPLICATE KEY UPDATE
        list_order = VALUES(list_order),
        food = VALUES(food),
        price = VALUES(price);

    I too normally like the food[x][field] naming method, but this insert/update method would require that all the new ones all had zero id. As array keys can't be duplicated then using the id in the field naming becomes a problem.

    I would also use a hidden id field but go with

    List order <input type="text" name="list_order[]" value="<?= $result['list_order']?>"><br>
    Food item <input type="text" name="food[]" value="<?= $result['food']?>"><br>
    Price (each) <input type="text" name="price[]" value="<?= $result['price']?>">
    <input type="hidden" name="id[]" value="<?= $result['id']?>">

    using 0 instead of $result['id'] for the id values in the new ones

    Ok I think I understand this.  But I may have more than one new field, would I be right in that I use [][] instead ?

  4. Been working on this for some time now and managed to get the new form fields added but the numbering and ids are not setup so i can submit/process the form.

    while($result = $fetch->fetch_assoc()) { ?>
    List order <input type="text" name="food[<?php echo $result['id'];?>][list_order]" id="list_order" value="<?php echo $result['list_order'];//htmlentities($itemDetails['title'], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");?>"><br>
    Food item <input type="text" name="food[<?php echo $result['id'];?>][food]" id="food" value="<?php echo $result['food'];//htmlentities($itemDetails['title'], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");?>"><br>
    Price (each) <input type="text" name="food[<?php echo $result['id'];?>][price]" id="price" value="<?php echo $result['price'];//htmlentities($itemDetails['title'], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");?>">
    <br><br><?php
    }
    ?><div id="addFields">
    </div>
    <a href="javascript:void();" onClick="addField('food');">Add Field</a><br><br>
      function addField(name) {
        var EL       = document.getElementById('addFields');
        var fieldNum = (EL.children.length)+1;
        var HTML     = '';
    
        for(i=0; i<EL.children.length; i++) {
    	var total = (EL.children[i].children[0].value) + 1;
          HTML += '<div>List order <input type="text" name="food[][list_order]" id="list_order" value="'+total+'"><br>Food item <input type="text" name="food[][food]" id="food" value=""><br>Price (each) <input type="text" name="food[][price]" id="price" value=""><br><br></div>';
        }
    
        HTML += '<div>List order <input type="text" name="food[][list_order]" id="list_order" value="'+fieldNum+'"><br>Food item <input type="text" name="food[][food]" id="food" value=""><br>Price (each) <input type="text" name="food[][price]" id="price" value=""><br><br></div>';
    
        EL.innerHTML = HTML;
      }

    Say there are already 5 items showing numbered 1 to 5 (when submitted I will add/change the items as edited, if any.  And insert the new items if any.  If new items then these will get added to the DB without an ID as it will auto assign this.  The list order is to allow the users to add new items and state in which order they show on the end user page.

    My issue is how to add new items to the form and get these processed from the backend php even though there is no ID.

    Just a thought, should I have two POSTS, one for existing items and a 'new' POST information sent that I can insert in the DB ?

    Not sure how best to do this one.

    Does anyone have any ideas on a way that would work ?

  5. I have not used radio buttons but a long time.

    I wish to have an approve page show the images with keep or delete radio buttons underneath.  There would be a few images showing at any one time waiting to be checked.  I do not need a default selection for any as they admins can leave them and check again another time.

    <div class="floatLeft">
    <img class="maxwidth" src="uploads/S<?php echo($result['img_name']); ?>">
    </div>
    <div class="floatLeft">&nbsp;&nbsp;<strong>Username:</strong><?php echo(htmlentities($result['user_name'])); ?></div><br>
    <div class="floatLeft">&nbsp;&nbsp;<strong>Description:</strong> <?php echo($result['description']); ?></div><br>
    <div class="floatLeft">&nbsp;&nbsp;<?php echo($result['created']); ?></div><br>
    <div class="clearFloat"></div>
    <div class="floatLeft"><input type="radio" name="list[]" value="<?php echo($result['id']); ?>">Approve</div>
    <div class="floatLeft"><input type="radio" name="del[]" value="<?php echo($result['id']); ?>">Delete</div>
    <div class="clearFloat"></div>

    The radio buttons is where I am having issues. They work but not as needed as I am able to select both delete and approve for only one.

    Looking to have it grouped by photo.  I am not sure how I should group each photo seperately.

  6. I would like to cater for all devices/pc.  I just tried the if statement you gave and it allowed

    ssss@gg@.gfh

    Just checking that the email is looking ok is fine, i.e. no spaces, no strange characters and that. They could still type in thisemaildoesnotexists@gmailfake.com  but then we'd see that when we go to reply !

  7. Thank you for this, but how do I add this in to my existing code like above ?

    I already have the errormessage added to the top of the field if it is needed.

    I already have it checked server side but still could fail when we reply to their message anyway.

  8. I just can not seem to find a javascript code that checks if the email format is correct. I know that someone could enter an bogus email address but thats ok. I am just after checking if the format of the email entered looks correct before the form is submitted.
    Please can I have some suggestions of what others have used.

    It could be that I am doing this wrong...

    if (/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email.value.lrtrim())) {
    errorMessage = 'Email contains invalid character/s';

  9. I thought that at first but there is a large unsubscribe link (three times the size of other text) which is why I placed it on a line of its own at the bottom of the email.  The length of the email is never more than one standard screen length.

    I manually sent the mailshot from my pc to a few that bounced back as it was thought to be spam and the person got it.  We even contacted a few of them by phone to see if they were filtering any email but no one is.  But still it does not explain why say 20 fail one time and another ten fail yet another time, rarely two return from the same email address.

    Just a thought...

    So if the server was to auto send out say 100 and a number of them returned undelivered due to it might be spam, should I stop there and then from sending out any more from that batch to be sent and wait a short time before resuming to prevent some of the rest from being seen as possible spam?

  10. Setup of the email takes no more than a few minutes.  My host has already set up SPF and DKIM.  As for bounce rate one bounce and I have to manually check the returned email to decide if the customers email address (if exists still) will get any more emails.  Out of the 500 ish subscribers we might get 2 or 3 that come back as no longer found as the employee does not work for that company anymore.

    The ones that I am worried about are the 20 or 30+ that come back and not delivered due to spam score rating.  They are completely random and not the same customer email.  Otherwise it would be that these customers are marking it as such.

  11. This has been an ongoing issue from the start.

    When I try to login I enter the username and password and click login, then get taken back to the login page to reenter the same details and the second time I click login I get logged in.  Now if I then log out and close window and wait a few seconds, restart again and try to log in, I get in first time.  I believe this could be a session issue but I thought unsetting the unset($_SESSION['admin']); would cause the session to be lost and have to start again.

    I just can not get my head around what is causing it.  Can anyone tell me what I might be doing wrong ?

    I have a redirect to originating page, so if I was to view a previous page within the admin area I have to log in and then once loggeed in it will redirect to the page I was on before.

    Here are my scripts.


    adminCreateCampaign.php

    <?php
    session_set_cookie_params(0, '/', '.****.com'); session_start(); error_reporting(-1);
    
    define('site_title', 'Admin ');
    define('pageTitle', 'Admin ');
    $_SESSION['loginRedirect'] = "adminCreateCampaign.php";
    
    include("functions-for-email.php");
    
    $checkAdminStatus = checkAdminStatus($mysqli);
      if(!isset($_SESSION['admin']) || $checkAdminStatus == "NOACCESS") {
        $_SESSION['error'] = 'You must be logged in to view that page. (el.S1)';
        //$_SESSION['loginRedirect'] = "showStats.php";
    //echo("You must be logged in to view that page. (el.S1)<br>"); exit;
        @mysqli_close($mysqli);
        header('Location: ' . adminFullWebAddress . '/index.php'); exit;
      } else {
        if($_SESSION['admin']['account_type'] != 'admin') {
          $_SESSION['error'] = 'You do not have the priviledges to view that page. (el.S2)';
          @mysqli_close($mysqli);
          header('Location: ' . adminFullWebAddress . '/index.php'); exit;
        }
      }
    ?>
    <!DOCTYPE>
    <html>
    <head>
    <link href="adminstyle.css" rel="stylesheet" type="text/css" />
    <title><?php echo(site_title); ?></title>
    </head>
    <body>
        <div id="container">
    
                                    <div class="containerInner">
                                    <div id="leftInner100">
                                    <?php // start of leftInner ?>
    
    <?php menu(); ?>
    
                        <h1 class="middleTitle">Admin </h1>
                        <?php
                        if(isset($thisError)) { echo '<div class="errorDiv">',$thisError,'</div>'; unset($thisError); }
                        if(isset($thisSuccess)) { echo '<div class="successDiv">',$thisSuccess,'</div>'; unset($thisSuccess); }
                        ?>
    
                        
                        <br><br>
                                    </div><?php //    end of leftInner ?>
                                    </div><?php // end of containerInner ?>
    
            <div class="clearfix"></div>
    
        </div><?php // container ?>
    </body>
    </html>
    <?php @mysqli_close($mysqli); ?>


    index.php

    <?php
    session_set_cookie_params(0, '/', '.****.com'); session_start(); error_reporting(-1);
    include("functions.php");
    $checkAdminStatus = checkAdminStatus($mysqli);
    //$_SESSION['loginRedirect'] = adminFullWebAddress . "/index.php";
    $fromlink4 = isset($_SERVER['REMOTE_ADDR']) ? (gethostbyaddr($_SERVER['REMOTE_ADDR'])) : "empty";
    $ipAddress = $_SERVER['REMOTE_ADDR'];
    
        if(isset($_POST['email'])) { $email = $_POST['email']; $email = strip_tags($email); } else { $email = ""; }
        if(isset($_POST['pass'])) { $password = $_POST['pass']; $pass = $_POST['pass']; } else { $pass = ""; }
        if(isset($_POST['login']) && trim($_POST['login']) == 'Login') {
                $checkEmail        = db_query($mysqli, "SELECT `adminid` FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($email) . "' LIMIT 1");
                $checkBanned    = db_query($mysqli, "SELECT `adminid` FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($email) . "' AND `suspended` = 'Yes' LIMIT 1");
                $failedLoginCounter    = 0;
    
                if(!$email) {
                    $thisError = 'Please enter your e-mail address.';
                } else if(! $checkEmail->num_rows) {
                    $thisError = 'Either the email address, password or both were not entered correctly.';
                } else if(!$password) {
                    $thisError = 'Please enter your password.';
                } else if($checkBanned->num_rows) {
                    $thisError = 'Your account has been suspended by Admin.';
                } else {
                        $password = md5($password);
                        $checkAccount = db_query($mysqli, "SELECT * FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($email) . "' AND `password` = '" . $mysqli->real_escape_string($password) . "' LIMIT 1");
                            if($checkAccount->num_rows) {
                            $saveChanges = db_query($mysqli, "UPDATE `admins` SET `lastlogindatetime` = '" . $mysqli->real_escape_string(datetimenow) . "', `lastAccessSinceLogin` = '" . $mysqli->real_escape_string(datetimenow) . "', `lastloginip` = '" . $mysqli->real_escape_string($ipAddress) . "', `failedLoginCounter` = 0 WHERE `email` = '" . $mysqli->real_escape_string($email) . "' LIMIT 1");
                            // set lastlogindatetime
                            $_SESSION['admin'] = $checkAccount->fetch_assoc();
                            $loginRedirect = isset($_SESSION['loginRedirect']) ? $_SESSION['loginRedirect'] : "";
                            $_SESSION['success'] = 'You are now logged in. (ok.L2) ' . $loginRedirect;
                                  header('Location: ' . adminFullWebAddress . '/' . $loginRedirect); exit;
                            } else {
                                    $thisError = 'Your e-mail address and/or password is incorrect.<br>If you still face issues, you can <a href="startresetpw.php">reset your password</a>';
                                    $saveChanges = db_query($mysqli, "UPDATE `admins` SET `failedLoginCounter` = `failedLoginCounter` + 1, `lastloginfailedip` = '" . $mysqli->real_escape_string($ipAddress) . "', `lastlogindatetimeFailed` = '" . $mysqli->real_escape_string(datetimenow) . "' WHERE `email` = '" . $mysqli->real_escape_string($email) . "' LIMIT 1"); // set lastlogindatetimeFailed
                                     }
                        }
        }
    if(!isset($_SESSION['admin'])) {
    define('site_title', 'Login');
    define('pageTitle', 'Login');
    } else {
    define('site_title', 'Home');
    define('pageTitle', 'Home');
    }
    ?>
    <!DOCTYPE>
    <html>
    <head>
    <link href="adminstyle.css" rel="stylesheet" type="text/css" />
    <title><?php echo(site_title); ?></title>
    </head>
    <body>
        <div id="container">
                <div class="containerInner">
                <div id="leftInner100">
                <?php // start of leftInner ?>
    
                    <div id="mainphoto"><?php //specialMessage($mysqli); mainPageImage(""); ?></div>
                    <div class="clear"></div><?php
    
                        if(isset($_SESSION['admin'])) {
                            menu();
                        }
    
                        if(isset($thisError)) { echo '<div class="errorDiv">',$thisError,'</div>'; }
                        if(isset($thisSuccess)) { echo '<div class="successDiv">',$thisSuccess,'</div>'; }
                        unset($thisError); unset($thisSuccess);
    
                            if(!isset($_SESSION['admin'])) { ?>
                                    <div style="width: 100%; margin: 0em auto; text-align: center;">
                                        <form method="POST" action="index.php" style="width: 15em; text-align: center;">
                                          <div class="field"> E-mail Address </div>
                                          <div class="value"> <input type="text" name="email" value="<?php if(isset($_POST['email'])) { echo $email; } ?>" style="width: 12.5em;" title="email"> </div>
                                              <div class="field"> Password<br><span style="font-size: 0.8em;"><?php
                                              if (isset($_POST['pass'])) { echo('<strong style="color: red;">'); } ?>(Please note: your password may be CaSe SeNSitIvE)<?php if (isset($_POST['pass'])) { echo('</strong>'); } ?></span>
                                              </div>
                                          <div class="value"> <input type="password" name="pass" value="" style="width: 12.5em;" title="pass"> </div>
                                          <div><br><input type="submit" name="login" value="Login"> <input type="reset" value="Clear"><br></div>
                                        </form><br>
                                      <div class="clearFloat"></div>
                                    </div>
                            <?php
                            } else { ?>logged in<?php } ?>
    
                <br><br>
                </div><?php //    end of leftInner ?>
                </div><?php // end of containerInner ?>
            <div class="clearfix"></div>
        </div><?php // container ?>
    </body>
    </html>
    <?php
    @mysqli_close($mysqli); ?>

    functions.php

    <?php
    define('showOutput', 0);
    
    include("/home/****/db_login_functions.php");
    define('db_table_name', 'clientList');
    define('mailHost', 'mail.****.com');
    define('mailUsername', 'noreply@****.com');
    define('mailPW', '****');
    
    define('bounce', 'bounce@****.com');
    
    define('fullDomain', 'https://www.admin.****.com');
    define('adminFullWebAddress', 'https://www.admin.****.com');
    define('adminEmail', 'admin@****.com');
    define('fromEmail', 'noreply@****.com');
    define('fromName', 'DO NOT REPLY');
    define('REMOTEADDR', isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '');
    define('PHPSELF', $_SERVER['PHP_SELF']);
    define('HTTPREFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "not set");
    
    define('unsub', 'https://www.****.com/unsub.php'); define('securityhash', 'abc'); // NEVER change this securityhash.
    
    date_default_timezone_set('Europe/London');
    define('datetimenow', date("Y-m-d H:i:s"));
    
    /*        check if user is allowed to access a certain page or not.    */
    function checkAdminStatus($mysqli) { $yesNo = "";
    
        if(isset($_GET['action']) && $_GET['action'] == 'logout') {
            unset($_SESSION['admin']);
            $_SESSION['success'] = 'You have successfully logged out. (lo.1)';
            header('Location: index.php'); exit;
        }
        if(isset($_SESSION['admin']) ) {
            //            need to add in code to check if logged in for more than 1 hour, if so log out on next refresh of page.
            if ($_SESSION['admin']['lastAccessSinceLogin'] < date( 'Y-m-d H:i:s', strtotime("-5 minutes") )) {        unset($_SESSION['admin']);
            $_SESSION['error'] = 'You were logged out due to no activity, please login again to view that page. (lo.2)';
            header('Location: index.php'); exit;
            }
        $checkBanned    = db_query($mysqli, "SELECT `adminid` FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($_SESSION['admin']['email']) . "' AND `suspended` = 'Yes' LIMIT 1");
            if($checkBanned->num_rows) {        $yesNo = "NOACCESS";        //$_SESSION['error'] = 'You must be logged in to view that page.';
            } else {        $yesNo = "ACCESS";        // if logged in, update        `users`.`lastAccessSinceLogin`        with current datetime.
            $updateLastAccessSinceLogin = db_query($mysqli, "UPDATE `admins` SET `lastAccessSinceLogin` = '" . $mysqli->real_escape_string(datetimenow) . "', `lastloginip` = '" . $mysqli->real_escape_string(REMOTEADDR) . "', `failedLoginCounter` = 0 WHERE `email` = '" . $mysqli->real_escape_string($_SESSION['admin']['email']) . "' LIMIT 1");
            $_SESSION['admin']['lastAccessSinceLogin'] = datetimenow;
            }
        }
    
    return $yesNo;
    }
    
    function menu() {
    echo('<a href="index.php?action=logout">Log Out</a>&nbsp;&nbsp;&nbsp;&nbsp;');
    echo('
    <a href="adminCreateCampaign.php">Create Campaign</a><br><br><br>');
    }
    ?>

     

    .htaccess (within the admin folder)

    Header set Access-Control-Allow-Origin "*"
    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    # First rewrite to HTTPS:
    # Don't put www. here. If it is already there it will be included, if not
    # the subsequent rule will catch it.
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Now, rewrite any request to the wrong domain to use www.
    # [NC] is a case-insensitive match
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    ### DON'T DELETE!! Below entry is MUST for your PHP sites like wordpress,joomla and etc to work properly.
    suPHP_ConfigPath /home/****/php.ini

    .htaccess (within the root folder)

    Header set Access-Control-Allow-Origin "*"
    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    # First rewrite to HTTPS:
    # Don't put www. here. If it is already there it will be included, if not
    # the subsequent rule will catch it.
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Now, rewrite any request to the wrong domain to use www.
    # [NC] is a case-insensitive match
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    ### DON'T DELETE!! Below entry is MUST for your PHP sites like wordpress,joomla and etc to work properly.
    suPHP_ConfigPath /home/****/php.ini

    the php.ini file

    allow_url_fopen = on
    allow_irl_include = on
    date.timezone = Europe/London
    safe_mode = off
    upload_max_filesize = 20M
    post_max_size = 20M
    upload_tmp_dir = "/home/****/tmp"
    session.save_path = "/home/****/sessions"
    session.use_only_cookies = on
    error_reporting = E_ALL
    log_errors = On
    display_errors = Off
    track_errors = On
    error_log = "/home/****/errors.log"
    sendmail_from = "server@****.com"

     

  12. There are around 500 in the list. We are currently using the server to send out emails, one every minutes (cron job).  The issue is that a lot of them return due to possible spam.  I have the email sent using the actualy email login and tls.  But as with shared servers it gets added to block lists a lot.

    Sometime ago we used a few of the free email services but a lot of them have their advertising in which we wanted to do with out, so opted for the method we have now.

    I have a custom link in the email so they can quickly unsubscribe.  But looking as mailchimp and a few others none allow for custom stuff like that from what I read.

    I was wondering if ther is a config issue from our end that might cause it to be seen as spam, which it is not as they subscribed to it in the first place.

    as for MTA the server uses a system called relay.mailchannels.net

    ----

    Now if I was to send the email manually from my computer exact content as the automated one sent from the noreply address it goes through fine.  So I understand it is the servers IP that is the issue.  Is there a way to have the email sent like it was sent from my pc ?

  13. We use a shared server and have the same problems as many like us with emails not being delivered as it is seen as possible spam.

    What pc installed software is suggested to use to send out out emails to out mailing list but allows us to customise each email to the user.  The only few differences is the greeting text (Hi.. John) and the unsubscribe link that contains their email address and a hash that is stored on our server so we know that it is most likely them wanting to be removed.  The emails are all in HTML (tabled) format.

    Please suggest what programs you use.

    Thank you

  14. I don't have a solution for this particular problem, but after 10 years of programming, I think it's time to abandon Dreamweaver and switch to a professional IDE (PhpStorm, Netbeans, Eclipse, whatever). If you're into minimalism, there's Notepad++.

     

    And as a nice side effect, your tools will no longer fudge up your code.

    I downloaded Netbeans and installed it and like the look of it.  I have not had an major issues with uploading any of my custom written files directly to the server using DW. (from the errors point of view)

     

    I would really like to have it all setup just like I had with DW, where I edit the files and it saves it locally and then immediately to the server.  I have yet to go through all the settings to see what under the hood.  But did see something about saving locally for some testing server or something, will have to check that again.  Think I will check a bit more of the help pages as well.

     

    Are any of the settings files of the project saved to the server ?

     

    Change is good sometimes but only if it does not take away some of the original features that I was use to.

  15. When I open a file be it a html or in most of the cases a PHP file the view changes to what it was saved as.  So say I have indented a portion of text to 2 or 3 or more tab indents and save the file.  When I open it again in dreamweaver the tabs are still there, but the whole portion that was indented is now brought to the next line and taken to the first column and not indented as it was previously saved.  If I enit the file in notepad and open it the file is how it was saved as I wanted it.  But opening this file in DW and the code gets changed.

     

    I have looked through a lot of the settings nad can not find anything that has helped stop this.  Even the do not change files with certain extentions stops it.

     

    Is there another setting that I have missed that will stop this ?

  16. Please can someone advise how I correctly access each of the nodes in an XML file.

     

    echo($geoLocXML->isp . '<br>');

    this is what I used before and it worked up to last month, then all of a sudden it failed.  I have also tried this code on a different server and it fails there too, so it suggests there is an error in the code, but for the life of me I can not find it.

     

     

     

    <?php                //exit;
    
    error_reporting(-1);
    
    //$ip = $_SERVER['REMOTE_ADDR'];
    //$geoLocXML = getGeoLocXML($ip); //->result[0];
    //$geoLocXML = file_get_contents('http://api.geoiplookup.net/?query='.$ip);
    $getGeoLocXML = simplexml_load_file('http://www.mysite.com/getGeoLocXML.xml');
    
    /*
    $getGeoLocXML = '<?xml version="1.0" encoding="iso-8859-1"?        >
    <ip>
    <results><result><ip>123.123.123.123</ip><host>123.123.123.123</host><isp>Provider</isp><city>My City</city><countrycode>GB</countrycode><countryname>United Kingdom</countryname><latitude>123.123</latitude><longitude>-1.123</longitude></result></results>
    </ip>
    ';
    */
    
    $geoLocXML = $getGeoLocXML->result[0];
    echo($geoLocXML . '<br>');
    echo($geoLocXML->isp . '<br>');
    echo($geoLocXML[city] . '<br>');
    echo($geoLocXML[countryname] . '<br>');
    
    /*
    <results>
    <result>
    <ip>123.123.123.123</ip>
    <host>123.123.123.123</host>
    <isp>Provider</isp>
    <city>My City</city>
    <countrycode>GB</countrycode>
    <countryname>United Kingdom</countryname>
    <latitude>123.123</latitude>
    <longitude>-1.123</longitude>
    </result>
    </results>
    */
    ?>
    

     

     

    <?xml version="1.0" encoding="iso-8859-1"?>
    
    <ip>
    <results><result><ip>123.123.123.123</ip><host>123.123.123.123</host><isp>Provider</isp><city>My City</city><countrycode>GB</countrycode><countryname>United Kingdom</countryname><latitude>123.123</latitude><longitude>-1.123</longitude></result></results>
    </ip>
    
×
×
  • 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.