Jump to content

bravo14

Members
  • Posts

    296
  • Joined

  • Last visited

Everything posted by bravo14

  1. I found it on a tutorial to store a remember me cookie. I am not sure if the openssl_random_pseudo_bytes(4) part of the function is generating anything
  2. I am using the code below, to encrypt cookie, but the hex2bin is generating the following error Warning: hex2bin(): Input string must be hexadecimal string in $key = hex2bin(openssl_random_pseudo_bytes(4)); $cipher = "aes-256-cbc"; $ivlen = openssl_cipher_iv_length($cipher); $iv = openssl_random_pseudo_bytes($ivlen); $ciphertext = openssl_encrypt($value, $cipher, $key, 0, $iv); return( base64_encode($ciphertext . '::' . $iv. '::' .$key) ); Can anyone point me in the right firection to correct this?
  3. Hi all Using a from with this code <form class="search-form"> <input type="text" placeholder="Search..." id="txtSearch" autocomplete="off" value=""> <button id="btnSearch" class="search-btn"> <i class="flaticon-magnifying-glass"></i> </button> </form> and the jquery below <script type="text/javascript"> var q = $("#txtSearch").val(); $('#btnSearch').click(function(){ location.href = "/recipes/search/" + q; }); </script> I am trying to redirect to a page /recipes/search and then the inpit value from the search field, but the input value is not appending. I am hoping I am missing something simple?
  4. I have added the &c='+country that is where the problem is occurring, in this line var url = query + '&c='+country;
  5. Hi I am trying to pass 2 variables to a URL using typeahead, but the URL that it gerjneates is incorrectly formatted. The code I am using on the function is $('#txtLocation').typeahead({ source: function (query, process) { var country = $('#txtCountry').val(); var url = query + '&c='+country; //var uri = encodeURI(url); //alert(uri); return $.get('ajax/search_locations.php', { query: encodeURI(url) }, function (data) { data = $.parseJSON(data); return process(data); }); }, //showHintOnFocus:'all' }); The URL in the debugger is /ajax/search_locations.php?query=b%26c%3DUnited%2520Kingdom it should be /ajax/search_locations.php?query=b&c=United%2520Kingdom Any help or pointers on where I am going wrong would be fantastic
  6. Hi all I am trying to get the lat and long properties from the googlemaps geocoding api. $xml=simplexml_load_file($url); if ($xml === false) { echo "Failed loading XML\n"; foreach(libxml_get_errors() as $error) { echo "\t", $error->message; } } else{ $path = $xml->xpath( "/GeocodeResponse/result/geometry/location"); $lat = $path->lat; $lng = $path->lng; echo $lat; echo $lng; $sql1 = "UPDATE tbl_clubs set lat='$lat',lng='$lng' where club_id =$id"; echo $sql1; $result1 = mysqli_query($dbConn,$sql1) or die($mysqli_error($dbConn)); } This is the XML I am using <GeocodeResponse> <status>OK</status> <result> <type>establishment</type> <type>point_of_interest</type> <type>stadium</type> <formatted_address>Aldridge Rd, Perry Barr, Birmingham B42 2ET, UK</formatted_address> <address_component> </address_component> <address_component> </address_component> <address_component> </address_component> <address_component> <long_name>West Midlands</long_name> <short_name>West Midlands</short_name> <type>administrative_area_level_2</type> <type>political</type> </address_component> <address_component> <long_name>England</long_name> <short_name>England</short_name> <type>administrative_area_level_1</type> <type>political</type> </address_component> <address_component> <long_name>United Kingdom</long_name> <short_name>GB</short_name> <type>country</type> <type>political</type> </address_component> <address_component> <long_name>B42 2ET</long_name> <short_name>B42 2ET</short_name> <type>postal_code</type> </address_component> <geometry> <location> <lat>52.5196698</lat> <lng>-1.8986236</lng> </location> <location_type>GEOMETRIC_CENTER</location_type> <viewport> <southwest> <lat>52.5183208</lat> <lng>-1.8999726</lng> </southwest> <northeast> <lat>52.5210188</lat> <lng>-1.8972746</lng> </northeast> </viewport> </geometry> But I am getting the following response Notice: Trying to get property of non-object in /home/sites/1a/9/95f15f28a6/public_html/results/getLatLng.php on line 22 I am guessing my path is wrong, any guidance would be great
  7. Hi all I have a xml file that builds a league table, but want to provide other sites with access to it for a charge. Is there a way I can check the domain using the xml file has permission to do so? I intended on keeping a key in a database with the URL but how can I get the URL using the xml file?
  8. Think part of my problem is on some parts of the menu I will need to get menu options from a different table as well as the pages menu if that makes sense.
  9. Hi all Trying to build a multi level nav for bootstrap from a database below is the code I am using <?php $table = 'tbl_pages_'.$lang; $sql = "SELECT * FROM $table where parent_id = 0 and visible = 1 order by `order` asc"; //echo $sql; $result = mysqli_query($dbConn,$sql) or die(mysqli_error($dbConn)); if(mysqli_num_rows($result)>0){ ?> <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> <?php while($row = mysqli_fetch_assoc($result)){ if($row['page'] == 'riders'){ $pageId = $row['page_id']; //get rider information $table = 'tbl_riders_'.$lang; $sql2 = "SELECT * FROM $table where active = 1 order by `sort` asc"; $result2 = mysqli_query($dbConn,$sql2) or die(mysqli_error($dbConn)); if(mysqli_num_rows($result2) >0){ if($page == $row['page']){ echo '<li class="active dropdown">'; } else{ echo '<li class="dropdown">'; } echo '<a href="'.$shopConfig['url'].$row['link'].'" class="dropdown-toggle " data-hover="dropdown" data-toggle="dropdown">'.$row['menu_display']; echo '<b class="caret"></b></a>'; echo '<ul class="dropdown-menu">'; while($row2 = mysqli_fetch_assoc($result2)){ echo '<li><a href="'.$shopConfig['url'].$row['link'].'/'.$row2['id'].'/'.$row2['identifier'].'">'.$row2['rider_name'].'</a></li>'; } $table = 'tbl_pages_'.$lang; $sql3 = "SELECT * FROM $table where parent_id = $pageId and visible = 1 order by `order` asc"; //echo $sql3; $result3 = mysqli_query($dbConn,$sql3) or die(mysqli_error($dbConn)); if(mysqli_num_rows($result3)>0){ while($row3 = mysqli_fetch_assoc($result3)){ echo '<li><a href="'.$shopConfig['url'].$row3['link'].'">'.$row3['menu_display'].'</a></li>'; } } echo '</ul>'; echo '</li>'; } echo ''; } if(($row['page'] != 'shop') && ($row['page'] !='riders')){ $pageId = $row['page_id']; $pagetable = 'tbl_pages_'.$lang; $dropdown = ''; $subSQL = "SELECT * FROM $pagetable where parent_id = $pageId and visible =1 order by `order` asc"; //echo $subSQL; $subresult = mysqli_query($dbConn,$subSQL) or die(mysqli_error($dbConn)); $subRows = mysqli_num_rows($subresult); if($page == $row['page']){ if($subRows >0){ $dropdown = ' dropdown'; } echo '<li class="active'.$dropdown.'">'; } else{ if($subRows >0){ $dropdown = ' class="dropdown"'; } echo '<li'.$dropdown.'>'; } if($subRows > 0){ echo '<a href="'.$shopConfig['url'].$row['link'].'" class="dropdown-toggle " data-hover="dropdown" data-toggle="dropdown">'.$row['menu_display'].' <b class="caret"></b></a>'; echo '<ul class="dropdown-menu">'; while($row3 = mysqli_fetch_assoc($result3)){ echo '<li><a href="'.$shopConfig['url'].$row3['link'].'">'.$row3['menu_display'].'</a></li>'; } echo '</ul>'; } else{ echo '<a href="'.$shopConfig['url'].$row['link'].'">'.$row['menu_display'].'</a>'; } } } echo '</li>'; } else{ if($row['page'] =='shop' && $shopConfig['shop'] == 1 && $shopConfig['shop_status']=='2'){ if($page == 'shop'){ echo '<li class="active">'; } else{ echo '<li>'; } echo '<a href="'.$shopConfig['url'].$row['link'].'">'.$row['menu_display'].'</a></li>'; } ?> </ul> </div><!--/.nav-collapse --> </div> </nav> <?php } ?> this is the HTML it is rendering [code] <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> <li><a href="http://www.plymouthdevils.co/">Home</a><li><a href="http://www.plymouthdevils.co/sponsors">Sponsors</a><li class="active"><a href="http://www.plymouthdevils.co/news">News</a><li><a href="http://www.plymouthdevils.co/photos">Photos</a><li class="dropdown"><a href="http://www.plymouthdevils.co/riders" class="dropdown-toggle " data-hover="dropdown" data-toggle="dropdown">Riders<b class="caret"></b></a><ul class="dropdown-menu"><li><a href="http://www.plymouthdevils.co/riders/1/lee-smart">Lee Smart</a></li><li><a href="http://www.plymouthdevils.co/riders/2/henry-atkins">Henry Atkins</a></li><li><a href="http://www.plymouthdevils.co/riders/3/callum-walker">Callum Walker</a></li><li><a href="http://www.plymouthdevils.co/riders/4/richard-andrews">Richard Andrews</a></li><li><a href="http://www.plymouthdevils.co/riders/5/saul-bulley">Saul Bulley</a></li><li><a href="http://www.plymouthdevils.co/riders/6/steve-boxall">Steve Boxall</a></li></ul></li><li><a href="http://www.plymouthdevils.co/fixtures">Fixtures</a><li><a href="http://www.plymouthdevils.co/season-tickets">Season Tickets</a></li> </div> </div> [/code] I't's probably something obvious I've missed, but can't spot it.
  10. HI all Probable a very simple answer but I am struggling, I have a .htaccess file with specific rules, but I also want a line on there for any pages that aren't captuured by the previous rules. I currently have the following .htaccess RewriteRule ^news$ news.php [L] RewriteRule ^gallery$ gallery.php[L] RewriteRule ^fixtures$ fixtures.php [L] RewriteRule ^about-us$ profile.php [L] RewriteRule ^sponsors$ sponsors.php [L] RewriteRule ^contact$ contact-us.php [L] RewriteRule ^gallery/([^/\.]+)/([^/\.]+)?$ gallery.php?id=$1&identifier=$2 [L] RewriteRule ^news/([^/\.]+)/([^/\.]+)?$ news.php?id=$1&identifier=$2 [L] RewriteRule ^feed$ rss.php?lang=en [L] RewriteRule ^kids-club$ kids-club.php [L] RewriteRule ^business-club$ business-club.php [L] RewriteRule ^merchandise$ shop.php [L] RewriteRule ^ticket-office$ tickets.php [L] RewriteRule ^my-first-skid$ my-first-skid.php [L] RewriteRule ^riders$ riders.php [L] RewriteRule ^riders/([^/\.]+)/([^/\.]+)?$ riders.php?id=$1&identifier=$2 [L] RewriteRule ^wall-of-honour$ wall-of-honour.php [L] RewriteRule ^commercial$ commercial.php [L] RewriteRule ^travel$ travel.php [L] RewriteRule ^supporters-club$ supporters-club.php [L] RewriteRule ^live$ live.php [L] Rewrit­eRule ^([A-Z­a-z­0-9­-]+)$ page.p­hp?­page=$1 [L] All of them work except the bottom one, so if I was to type in the url of domain.com/season-tickets, I would want that rewritten to domain.com/page.php?page=season-tickets Any help would be great Thanks
  11. Hi all I am trying to update field values using AJAX and json. the ajax call is made using this code <script type="text/javascript"> $(document).ready(function() { $("#cboShipping").change(function() { var data = { subTotal:25, discount:0, shippingOption: $('#cboShipping').val() } $.ajax({ type:"POST", url:"library/setPostage.php", data: data, dataType:'json', success: function(data){ $('#hidshippingCost').val(shippingCost); $('#total').val(totalDisplay); $('#hidTotal').val(total); } }); }); }); </script> The PHP is <? require_once('config.php'); print_r($_POST); $zone = $_POST['shippingOption']; $query="SELECT * FROM tbl_shipping_zones where id = $zone"; echo $query; $result=mysqli_query($dbConn,$query); $row=mysqli_fetch_array($result); $shippingCost = $row['shipping_cost']; echo $shippingCost; $shippingZone = $row['name']; echo $shippingZone; $total = $_POST['subTotal'] + $shippingCost - $_POST['discount']; echo $total; $array=array( 'shippingCost' => $shippingCost, 'shippingCostDisplay' => displayAmount($shippingCost), 'shippingZone' => $shippingZone, 'total' => $total, 'totalDisplay' => displayAmount($total) ); print_r($array); echo json_encode($array); ?> The correct values are being generated in the php Th fields and div containers I am trying to update are in the HTML below <span id="total">£30.00</span> <input name="hidDiscountType" type="hidden" id="hidDiscountType" value="" /> <input name="hidDiscountCode" type="hidden" id="hidDiscountCode" value="" /> <input name="hidDiscount" type="hidden" id="hidDiscount" value="0" /> <input name="hidTotalDiscount" type="hidden" id="hidTotalDiscount" value="0" /> <input name="hidTotal" type="hidden" id="hidTotal" value="30" /></td> any guidance would be appreciated
  12. This is one of the functions I have used with the same result http://phppot.com/php/php-time-ago-function/ I will look at DateTime
  13. Hi all Trying to use a timeago function, however for a date and time for today of 2016-07-02 16:41:48 it is showing at 46 years ago. below is the function function ago($timestamp) { $diff = time() - (int)$timestamp; //echo $diff; if ($diff == 0) return 'just now'; $intervals = array ( 1 => array('year', 31556926), $diff < 31556926 => array('month', 2628000), $diff < 2629744 => array('week', 604800), $diff < 604800 => array('day', 86400), $diff < 86400 => array('hour', 3600), $diff < 3600 => array('minute', 60), $diff < 60 => array('second', 1) ); $value = floor($diff/$intervals[1][1]); return $value.' '.$intervals[1][0].($value > 1 ? 's' : '').' ago'; } and this is how I am displaying it echo '<span class="timeAgo">'.ago($row['date_time']).'</span>';
  14. Hi all I have set of code for elrte and elfinder, the code works fine on one hosting package from one provider, however the same code is not working on another hosting package from another provider. The code is as follows <script type="text/javascript" charset="utf-8"> $().ready(function() { var opts = { cssClass : 'el-rte', lang : 'en', allowSource : 1, // allow user to view source height : 450, // height of text area toolbar : 'normal', // Your options here are 'tiny', 'compact', 'normal', 'complete', 'maxi', or 'custom' cssfiles : ['http://www.wightwarriors.co/css/style.css'], // elFinder fmAllow : 1, fmOpen : function(callback) { $('<div id="myelfinder" />').elfinder({ url : 'http://www.wightwarriors.co/tapesup/library/connector.php', // elFinder configuration file. lang : 'en', dialog : { width : 900, modal : true, title : 'Files' }, // Open in dialog window closeOnEditorCallback : true, // Close after file select editorCallback : callback // Pass callback to file manager }) } //end of elFinder } $('.editor').elrte(opts); // id of textarea you want rich edit on }) </script> The error generated in firebug is below Notice</b>: Undefined index: extract in <b>/home/linweb41/i/iowislanders.co/user/htdocs/tapesup/library/elFinder.class.php</b> on line <b>321</b><br /> I don't understand why the same code works on one package but not another
  15. Hi all I am trying to display a list of images contained withina folder. I am using the following code <?php //Path to folder which contains images $dirname = $shopConfig['url'].'images/flags/'; //echo $dirname; //Use glob function to get the files //Note that we have used " * " inside this function. If you want to get only JPEG or PNG use //below line and commnent $images variable currently in use print_r(glob($dirname."*")); $images = glob($dirname."*.png"); //Display image using foreach loop foreach($images as $image){ //print the image to browser with anchor tag (Use if you want really ) echo '<a href="'.$image.'" target="_blank"><img src="'.$image.'" height="100" width="100" /></a>'; } ?> I know there are images within the folder, however when I print the array it is empty. Can anyone point out what is wrong with the code and where I have gone wrong? Thanks
  16. Thanks for the reply, I am trying to add it straight to the database through phpmyadmin and mySQL Workbench, and both of them are storing it as ??????
  17. Hi That is the plan, but in phantasm in it is showing as ??????? And on my page currently it shows as ?????? The page charaet is set to Utf-8
  18. Hi I am trying to store multiple languages e.g. Russian and English in one table, the charset for the table is utf8_general_ci when I add the russian characters to the table they are displayed as ??????? My question is, is it possible to store the multiple character sets in the table and how do I do this?
  19. Added the code as above but still having to authorise on every use
  20. Excuse my stupidity, I'm brand new to this, do I need to store the refresh token somewhere like a db
  21. I have added that to if (isset($_SESSION['token'])) { $client->setAccessToken($_SESSION['token']); echo '<code>' . $_SESSION['token'] . '</code>'; $client->getRefreshToken(); //echo '<code>'.$this->token['refresh_token'].'</code>'; } but I am still not getting a refresh token, and am having to login every time
  22. Hi all I am trying to use the YouTube API, and have the site built in such a way that a user deosn't need to authorise access every time. Below is the code I am using, however I am not getting a refresh token generated. <?php require '../../library/config.php'; // Call set_include_path() as needed to point to your client library. set_include_path($shopConfig['url'] . 'fullthrottle/videos/google-api/'); require_once 'google-api/src/Google/Client.php'; require_once 'google-api/src/Google/Service/YouTube.php'; /* * You can acquire an OAuth 2.0 client ID and client secret from the * {{ Google Cloud Console }} <{{ https://cloud.google.com/console }}> * For more information about using OAuth 2.0 to access Google APIs, please see: * <https://developers.google.com/youtube/v3/guides/authentication> * Please ensure that you have enabled the YouTube Data API for your project. */ $OAUTH2_CLIENT_ID = $youtube['client_id']; $OAUTH2_CLIENT_SECRET = $youtube['client_secret']; $REDIRECT = $shopConfig['url'].'fullthrottle/videos/upload.php'; $APPNAME = $youtube['app_name']; $ACCESS_TOKEN = $youtube['access_token']; $client = new Google_Client(); $client->setClientId($OAUTH2_CLIENT_ID); $client->setClientSecret($OAUTH2_CLIENT_SECRET); $client->setScopes('https://www.googleapis.com/auth/youtube'); $client->setRedirectUri($REDIRECT); $client->setApplicationName($APPNAME); $client->setAccessType('offline'); // Define an object that will be used to make all API requests. $youtube = new Google_Service_YouTube($client); if (isset($_GET['code'])) { if (strval($_SESSION['state']) !== strval($_GET['state'])) { die('The session state did not match.'); } $client->authenticate($_GET['code']); $_SESSION['token'] = $client->getAccessToken(); } if (isset($_SESSION['token'])) { $client->setAccessToken($_SESSION['token']); //echo '<code>' . $_SESSION['token'] . '</code>'; } // Check to ensure that the access token was successfully acquired. if ($client->getAccessToken()) { try { // Call the channels.list method to retrieve information about the // currently authenticated user's channel. $channelsResponse = $youtube->channels->listChannels('contentDetails', array( 'mine' => 'true', )); $htmlBody = ''; foreach ($channelsResponse['items'] as $channel) { // Extract the unique playlist ID that identifies the list of videos // uploaded to the channel, and then call the playlistItems.list method // to retrieve that list. $uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads']; //print_r ($channel); $playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array( 'playlistId' => $uploadsListId, 'maxResults' => 50 )); $htmlBody .= "<h3>Videos in list $uploadsListId</h3><ul>"; foreach ($playlistItemsResponse['items'] as $playlistItem) { print_r($playlistItem); $htmlBody .= sprintf('<li>'. $playlistItem['snippet']['title'].' <img src="'.$playlistItem['snippet']['thumbnails']['high']['url'].'" style="max-width:200px"/>'.$playlistItem['snippet']['description'].'</li>'); } $htmlBody .= '</ul>'; } } catch (Google_ServiceException $e) { $htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage())); } catch (Google_Exception $e) { $htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage())); } $_SESSION['token'] = $client->getAccessToken(); } else { $state = mt_rand(); $client->setState($state); $_SESSION['state'] = $state; $authUrl = $client->createAuthUrl(); $htmlBody = <<<END <h3>Authorization Required</h3> <p>You need to <a href="$authUrl">authorise access</a> before proceeding.<p> END; } ?> <!doctype html> <html> <head> <title>My Uploads</title> </head> <body> <?php echo $htmlBody;?> </body> </html> Also do I need to store the access tokens in a database at all for them to be used in the future? Thanks in advance
  23. Hi all I am trying to vertically align some images inside a list item as part of a jquery plugin, there is a fiddle here http://jsfiddle.net/87avs38f/ But I can't figure it out, any help would be great
  24. The I frame gets generated by the html editor (elrte)
×
×
  • 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.