Jump to content

Destramic

Members
  • Posts

    969
  • Joined

  • Last visited

Everything posted by Destramic

  1. ah ok thats good to know it compares to a utc timezone...but when i change the my system time (UTC + 1...) shouldnt that change the offset to something else other than 0 IE. 1? but yes im wanting to then translate the value to +00:00, +01:00 etc.. thank you for the useful information
  2. that worked like a dream...thanks one more thing im using var offset = new Date().getTimezoneOffset(); to get users timezone but when testing on my system its always returning 0...so im guessing i would have to compare it againts a utc timestamp to work out the difference to get the result im looking for?
  3. i've read and seen there are variations of what im trying to achieve but havent seen a exact example...what im trying to do is put a where clause in my query depending on if a set variable has a value CASE WHEN (@category_id IS NOT NULL) THEN LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id JOIN categories c ON c.category_id = sc.category_id AND c.category_id = :category_id END is this possible or have i just got the syntax wrong somewhere...thank you guys
  4. when trying to get the date var visitors_time = new Date(); i'll being back a result like Mon Oct 27 2014 20:54:55 GMT+0000 (GMT Standard Time) my issue is, is there a way of getting the end part with the brackets to not show up? ie. format the date?...ive googled but doesnt seem no simple solution like php to actually format the date to the way you'd like it thank you guys
  5. ive checked the control panel and there's no way i can change or add options to it
  6. i have just recently purchase a server but the ttimezone is way off on both php and mysql...i did a bit of reading to create my own php.ini file so i can change timezone but it doesnt seem to change root in phpinfo() php.ini date.timezone = "Europe/London" .htaccess <Files ~ "\.(ini)$"> order allow,deny deny from all </Files> SetEnv php.ini // same location as .htacess so im boggled to why my custom php.ini isnt being read also is there a way to customise a my.cnf file from my .htaccess to change settings? thank you
  7. this did the trick CONVERT_TZ(now(), '+00:00', '+05:00')
  8. ok great thanks...would that work the same if users timezone is -1? due to getting the user timezone via javascript it will return results as +1, -1 or 0 etc... although i could return the results as 00:00, -01:00, +01:00 etc.... thank you again
  9. hey guys im wondering how you would add or takeaway a hour from a timestamp in a database when trying to select it please? thank you
  10. thank you...ive found a easier way of getting most of the information i need now protected function fetch_data() { $ip = $this->get_ip(); $url = "http://www.geoplugin.net/json.gp?ip=" . $ip; $json = file_get_contents($url); $json = json_decode($json); $this->_ip = $ip; $this->_status = $json->{'geoplugin_status'}; $this->_city = $json->{'geoplugin_city'}; $this->_region = $json->{'geoplugin_region'}; $this->_area_code = $json->{'geoplugin_areaCode'}; $this->_dma = $json->{'geoplugin_dmaCode'}; $this->_country_code = $json->{'geoplugin_countryCode'}; $this->_country_name = $json->{'geoplugin_countryName'}; $this->_continent_code = $json->{'geoplugin_continentCode'}; $this->_longitude = $json->{'geoplugin_longitude'}; $this->_latitude = $json->{'geoplugin_latitude'}; $this->_region_code = $json->{'geoplugin_regionCode'}; $this->_region_name = $json->{'geoplugin_regionName'}; $this->_currency['code'] = $json->{'geoplugin_currencyCode'}; $this->_currency['symbol'] = $json->{'geoplugin_currencySymbol'}; $this->_currency['symbol_UTF8'] = $json->{'geoplugin_currencySymbol_UTF8'}; $this->_currency['exchange_rate'] = $json->{'geoplugin_currencyConverter'}; }
  11. im trying to make a script so i can get users details like longitude, latitude etc but im having trouble matching the html by regular expression here is the html below that im trying to extract the data from: any help or possible any alternative, suggested ways would be greatful thank you <td>Country:</td> <td><img src="/images/dot.gif" class="flag-16 gb" align="absmiddle" width="16" height="16" title="United Kingdom"> United Kingdom (GB)</td> </tr> <tr> <td>City:</td> <td>Newport</td> </tr> <tr> <td>Region:</td> <td>Newport</td> </tr> <tr> <td>Latitude:</td> <td>51.5833</td> </tr> <tr> <td>Longitude:</td> <td>-2.9833</td> </tr> <tr> <td>Timezone:</td> <td>Europe/London</td> <?php $url = "http://smart-ip.net/geoip/2.101.108.124/"; $ch = curl_init(); $timeout = 0; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $rawdata = curl_exec($ch); curl_close($ch); if (preg_match('/<td>Country:</td><td>[img](?P<country>\w+)</td>/$', $rawdata, $match)) { $country = $match['country']; } if (preg_match('/<td>City:</td><td>(?P<city>\w+)</td>/$', $rawdata, $match)) { $city = $match['city']; } if (preg_match('/<td>Region:</td><td>(?P<region>\w+)</td>/$', $rawdata, $match)) { $region = $match['region']; } if (preg_match('/<td>Latitude:</td><td>(?P<latitude>\d+)</td>/$', $rawdata, $match)) { $latitude = $match['latitude']; } if (preg_match('/<td>Longitude:</td><td>(?P<longitude>\d+)</td>/$', $rawdata, $match)) { $longitude = $match['longitude']; } if (preg_match('/<td>Timezone:</td><td>(?P<timezone>\w+)</td>/$', $rawdata, $match)) { $timezone = $match['timezone']; } ?>
  12. just what i needed...saved me a lot of time and effort...thank you
  13. hey guys ive been using this regual expression for my configuration files to get the variable and value ie. db_username = blah db_password = blah but im in need of some help on the regular expression so that the value can be any character instead of just A-Za-z0-9_.:\/ this is what im using at the moment '/([A-Za-z0-9_]+) += +([A-Za-z0-9_.:\/]+)/' ive tried altering it to '/([A-Za-z0-9_]+) += +(.*)/' but doesnt seem to work at all any help would be truly greatful...thank you guys
  14. im using dom to tidy up my html but i wondering is there a way to format my html like so <dl> <dd> <label>Condition :</label> <select name="condition"><option value="New">New</option> </dd> </dl> insead of <dl> <dd> <label>Condition :</label> <select name="condition"><option value="New">New</option> </dd> </dl> here is the php im using $dom = new DOMDocument(); $dom->loadHTML($this->_body); $dom->formatOutput = true; echo $dom->saveHTML(); thank you
  15. hey guys...im after a it of advise regarding wrapping html using a decorator...below i have a label class where im able to send attributes to a method and render a <label> tag. but what i'm confused at is the design pattern to wrap the <label> tag... $label = new Label; $label->render(array('for' => 'name', 'label' => 'Destramic')); // returning <label for="name">Destramic</label> but what would be the best way to wrap say a <div> tag around the label?...if anyone could help of have a tutorial on a good way of doing this...thank you <?php namespace Form\View; use HTML\Decorator as Decorator; class Label extends Decorator { protected $_attributes = array('for', 'form'); public function open_tag(array $attributes) { if (array_key_exists('label', $attributes)) { $label = $attributes['label']; } else { $label = " "; } $tag = sprintf("<label %s>%s", $this->create_attributes_string($attributes), $label); return $tag; } public function close_tag() { return "</label>\n"; } public function render(array $attributes) { return $this->open_tag($attributes) . $this->close_tag(); } } decorator <?php namespace HTML; class Decorator { protected $_html; protected $_global_attributes = array('accesskey', 'class', 'contenteditable', 'contenteditable', 'dir', 'draggable', 'dropzone', 'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title', 'translate'); public static $_placement = "PREPEND"; public function set_html($html) { $this->_html = $html; } public function wrap() { } public function create_attributes_string(array $attributes) { $string = null; $count = count($attributes); $i = 0; foreach ($attributes as $attribute => $value) { $i++; $global_attribute = substr($attribute, 0, 5); if (in_array($attribute, $this->_attributes) || in_array($attribute, $this->_global_attributes) || $global_attribute == "data-") { if ($count == $i) { $string .= $attribute . '=' . '"' . $value . '"'; } else { $string .= $attribute . '=' . '"' . $value . '" '; } } } return $string; } }
  16. hey guys i know there is various script about to locate user (country, latitude and longitude) by ip...but can anyone suggest a good one which is free please? thank you
  17. CASE WHEN @category = 'All' THEN NULL ELSE LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id JOIN categories c ON c.category_id = sc.category_id AND c.name = :category END i think i've tried them all if statements , case, but keeps returning error in those lines....please has anyone any ideas or advise? the only way possible i can see at the moment is to alter the query via a php if statements...thank you
  18. just having problem with syntax in the case now...im hoping this will work SELECT @category = 'Videos', i.item_id, i.title, i.price, i.p_and_p, (i.price + i.p_and_p) AS `total_price`, i.listing, i.condition, CONVERT_TZ(DATE_ADD(i.start_date_time, INTERVAL concat(i.listing_duration) DAY), '+00:00', u.time_zone) AS `end_date_time`, cu.code AS `seller_currency_code`, cu2.code AS `buyer_currency_code`, cu2.symbol AS `buyer_currency_symbol` FROM items i LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id LEFT JOIN categories c ON c.category_id = sc.category_id CASE @category WHEN @category != 'ALL' THEN AND c.name = @category END LEFT JOIN users u ON u.user_id = i.user_id LEFT JOIN currencies cu ON cu.currency_id = u.currency_id LEFT JOIN users u2 ON u2.user_id = '7' LEFT JOIN currencies cu2 ON cu2.currency_id = u2.currency_id AND i.start_date_time < NOW() AND DATE_ADD(i.start_date_time, INTERVAL concat(i.listing_duration) DAY) >= NOW() GROUP BY i.item_id
  19. ummm actually it isn't working right...when :category = 'All' it doesn't load all items like i want but just causes a error...probably due to the fact there isn't a category name called All if category ALL i want to load all items regardless of category...but if category = a category then load items within that category =/ help anyone please
  20. LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id JOIN categories c ON c.category_id = sc.category_id AND (c.name = ':category' OR ':category' != 'All') that has seemed to work...so if category is ALL then it will show all regardless of the category...but if category is VIDEOS for instance it will load all VIDEOS...thank you for your help guys
  21. that worked great thank you...any ideas with the case?...i could use a php if statement but surly there must be a way with sql?
  22. lovely...thank you for your help
  23. Destramic

    case help

    hey guys im having a few problems with my query if anyone can please help...the two problems im having is 1.the total price returning as 00106. price = 100.00 and p_and_p = 6.00 in the database...im after a figure that looks like 106.00 2. @category will be a parameter like :category which will be binded to a value like 'al'l, 'videos', 'dvd's', but if the parameter is ALL i dont want to join my categories table allowing it to select all rows regardless of the category any help, pointer would be truly appreciated...thank you SELECT @category := 'Videos', i.item_id, i.title, i.price, i.p_and_p, SUM(i.price + i.p_and_p) AS `total_price`, i.listing, i.condition, CONVERT_TZ(DATE_ADD(i.start_date_time, INTERVAL concat(i.listing_duration) DAY), '+00:00', u.time_zone) AS `end_date_time` FROM items i LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id CASE @category != 'All' THEN LEFT JOIN categories c ON c.name = 'Videos' END CASE JOIN users u WHERE u.user_id = '7' AND MATCH (i.title, i.description) AGAINST ('bla' IN BOOLEAN MODE) AND i.start_date_time < NOW() AND DATE_ADD(i.start_date_time, INTERVAL concat(i.listing_duration) DAY) >= NOW() GROUP BY i.i
  24. thank you guys for your input so in essence dont use add/strip_slashes and mysqli_real_esapce_string() but with every input ($_POST from user i should use htmlspecialchars() ? thank you agian
  25. hey guys i was generally wondering...is it good practice to add_slashes and use mysqli_real_escape_string when entering data into the database? then to strip slashes when extracting rows? is this the right way to go around things...thanks
×
×
  • 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.