Jump to content

unplugged_web

Members
  • Posts

    897
  • Joined

  • Last visited

Everything posted by unplugged_web

  1. Thank you , that's perfect
  2. I'm working on adding Pay By Amazon to a site but have run into a problem. I think is quite easy to sort, but I'm not sure how. Each item has to have the prefix "PurchaseItems.PurchaseItem." and then an integer. How do I change that for each product so for the first product everything would be listed with the prefix PurchaseItems.PurchaseItem.1 the second would be PurchaseItems.PurchaseItem.2 etc? The full code is: <form action="https://payments.amazon.co.uk/cba/api/purchasecontract/" method="get"><input type="hidden" name="Action" value="SetPurchaseItems" /><input type="hidden" name="AWSAccessKeyId" value="SAMPLE" /><input type="hidden" name="PurchaseContractId" value="<?php echo $_GET['purchaseContractId']; ?>" /><?php foreach( $order_line as $key=>$value ) { ?><input type="hidden" name="PurchaseItems.PurchaseItem.1.FulfillmentNetwork" value="MERCHANT" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.MerchantId" value="SAMPLE" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.MerchantItemId" value="<?php echo $products_all[$value['product_id']]['id'] ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.Quantity" value="<?php echo $value['product_qty'] ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.Title" value="<?php echo htmldisplay( $products_all[$value['product_id']]['name'] ) ?>" /><?php if( count( $value['detail'] ) ) { ?><?php if( is_array( $product_detail ) ) { foreach( $product_detail as $key2=>$value2 ) { if( isset( $value['detail'][$key2] ) ) { ?><input type="hidden" name="PurchaseItems.PurchaseItem.1.Description" value="Option: <?php echo htmldisplay( $value2['name'] ) ?>" /><?php } } ?><input type="hidden" name="PurchaseItems.PurchaseItem.1.UnitPrice.Amount" value="<?php if( $value['price_total']<0.01 ) { echo "00.00"; } else { echo (number_format( $value['price_total']/$value['product_qty']*$companydetails['exchange'],2 )); } ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.UnitPrice.CurrencyCode" value="<?php echo htmldisplay( $companydetails['currency_iso']); ?>" /><input type="hidden" name="PurchaseItems.PurchaseItem.1.URL" value="product/<?php echo $products_all[$value['product_id']]['linkword'] ?>" /><?php } } } ?><input type="hidden" name="SignatureSignature" value="SAMPLE" /><input type="hidden" name="SignatureMethod" value="METHOD" /><input type="hidden" name="SignatureVersion" value="SIGNATUREVERSION" /><input type="hidden" name="Timestamp" value="TIMESTAMP" /><input type="hidden" name="Version" value="VERSION" /><input type="submit" class="input_button input_red" value="Complete order" /></form>
  3. I added everything inside another div and now it works
  4. Thanks, I'll give that a go. I think the problem is when the images are loaded it also loads a button for each of them, but on the static page I can load just two (one for the left and one for the right)
  5. I've added a 'hide/show' to some buttons and they work great until I roll over them then they go mad. I've set it so that when you roll over the 'tab' div the buttons show but as soon as you roll over either the 'right_arrow' or 'left_arrow' they start to repeat the function over about 10 times before they stop - how do I stop that? <script type="text/javascript">$(function(){//ARROWS $('#tabb').hover( function(){ automode=0;$("#left_arrow").animate({left: 0},'swing').show(); },function(){ automode=1;$("#left_arrow").animate({left: -100},'swing').hide(200); } ); $('#tabb').hover( function(){ automode=0;$("#right_arrow").animate({right: 0},'swing').show(); },function(){ automode=1;$("#right_arrow").animate({right: -100},'swing').hide(200); } ); });</script> <div id="tabb" style="position: relative; visibility: visible; overflow: hidden; width: 994px; height: 275px;"><div class="slide" style="position: absolute; left: -994px; width: 994px; height: 275px; text-align: center; visibility: hidden; z-index: 49;"><div style="width:994px;height:275px;display:table-cell;vertical-align:middle;"><a href="/products/bundles.php" target="undefined"><img src="/images/dynamic/new_product_bundles_carouselv2.jpg" style="border-width:0;"></a></div></div><div class="slide" style="position: absolute; left: -994px; width: 994px; height: 275px; text-align: center; z-index: 50; visibility: hidden;"><div style="width:994px;height:275px;display:table-cell;vertical-align:middle;"><a href="/products/lawhey2kg" target="undefined"><img src="/images/dynamic/lawhey-protein-best-shake.jpg" style="border-width:0;"></a></div></div><div class="slide" style="position: absolute; left: -994px; width: 994px; height: 275px; text-align: center; z-index: 51; visibility: hidden;"><div style="width:994px;height:275px;display:table-cell;vertical-align:middle;"><a href="/products/aj" target="undefined"><img src="/images/dynamic/aj-boxer.jpg" style="border-width:0;"></a></div></div><div class="slide" style="position: absolute; left: 0px; width: 994px; height: 275px; text-align: center; z-index: 52; visibility: visible;"><div style="width:994px;height:275px;display:table-cell;vertical-align:middle;"><a href="/about/shipping.php" target="undefined"><img src="/images/dynamic/uk_delivery_carousel_banner2.jpg" style="border-width:0;"></a></div></div></div> <div class="paginate" style="position: absolute; top: 25%; z-index: 1000; width: 994px;"><div id="left_arrow" style="position: absolute; left: -100px; display: none;"><a href="javascript:firstreel.navigate('back')" style="float:left;"><img src="/images/dynamic/arrow_left.png" /></a></div> <div id="right_arrow" style="position: absolute; right: -100px; display: none;><a href="javascript:firstreel.navigate('forth')" style="float: right;"><img src="/images/dynamic/arrow_right.png" /></a></div></div>
  6. I'm trying to change a carousel to have arrows either side controlling the background image. I can get it to work on a static page but the site is built completely with PHP so I'm not sure how to do this. I think what I need to do is have just a left and right button that change which image is shown when clicked. So far I've got this: PHP: <?php if( $value==1 && isset( $pagecontrol[1] ) ) { ?> <div id="tabblock"> <div style="width: 994px; height: 275px; position: relative;"> <?php foreach( $tabblock as $key=>$value2 ) { ?> <div class="tabb" id="tabb-<?php echo $key ?>" style="position: absolute;<?php if( $key!=$tabblock_init ) { ?> display: none;<?php } ?>"><a onclick="return clicktrack( 'tab',<?php echo $value2['id'] ?>,'' );" href="<?php echo $value2['url'] ?>"<?php if( $value2['newwin']==1 ) { ?> target="_blank"<?php } ?>><img src="/images/dynamic/<?php echo $value2['image'] ?>" alt="<?php echo htmldisplay( $value2['title'] ) ?>" title="<?php echo htmldisplay( $value2['title'] ) ?>" /></a></div> <?php } ?> <?php if( count( $tabblock )>1 ) { ?> <div id="tabctrl"> <?php foreach( $tabblock as $key=>$value2 ) { ?> <div id="tabb-cont-<?php echo $key ?>" class="tabb_tab <?php if( $key==$tabblock_init ) { ?> tabb_on<?php } else { ?> tabb_off<?php } ?>"> </div> <?php } ?> <?php echo $html_clear ?> </div> <?php } ?> </div> </div> Also the JavaScript for the 'tabs' is: <script type="text/javascript"> var currenttab=<?php echo $tabblock_init ?>; var lasttab=<?php echo count( $tabblock )-1 ?>; var automode=1; function acttab( oldid,id ) { $('#tabb-'+oldid).animate({left: -743},'swing',function(){ $(this).hide(); }); $('#tabb-'+id).css( 'left','743px' ); $('#tabb-'+id).show(); $('#tabb-'+id).animate({left: 0},'swing'); $('.tabb_tab').removeClass( 'tabb_on' ); $('.tabb_tab').addClass( 'tabb_off' ); $('#tabb-cont-'+id).removeClass( 'tabb_off' ); $('#tabb-cont-'+id).addClass( 'tabb_on' ); currenttab=id; } function autotabs() { if( automode==1 ) { var prevtab=currenttab; currenttab++; if( currenttab>lasttab ) { currenttab=0; } acttab( prevtab,currenttab ); } setTimeout( "autotabs()",10000 ); } setTimeout( "autotabs()",10000 ); $(document).ready(function() { $('.tabb_tab').hover(function(){$(this).css('cursor','pointer');},function(){}); $('.tabb_tab').click(function() { var id=$(this).attr("id"); id=id.replace( 'tabb-cont-','' ); if( currenttab!=id ) { acttab( currenttab,id ); } }); $('#tabblock').hover( function(){ automode=0;$("#tabctrl").slideDown( 200 ); },function(){ automode=1;$("#tabctrl").slideUp( 200 ); } ); }); </script> The Javascript for the 'click track' is: function clicktrack( type,id,loc ) { $.ajax({ async: false, type: "POST", url: "/ajax/clicktrack.php", data: { type: type, id: id, loc: loc } }); return true;} and the click track.php file is: if( empty( $_POST['id'] ) || !ctype_digit( $_POST['id'] ) ) { echo "no id received"; exit(); } else { if( $_POST['type']=="banner" ) { usedb( $country_modules[$ccode2]['db_web'],"dbLinkInt" ); $query="update front_banner_pool set clicks=clicks+1 where id=".dbstr( $_POST['id'] ); dbupdate( $query,"dbLinkInt" ); echo "ok"; exit(); } elseif( $_POST['type']=="tab" ) { usedb( $country_modules[$ccode2]['db_web'],"dbLinkInt" ); $query="update front_tabblock set clicks=clicks+1 where id=".dbstr( $_POST['id'] ); dbupdate( $query,"dbLinkInt" ); echo "ok"; exit(); } else { echo "no valid type received"; exit(); } } CSS: #tabctrl {display: block!important;padding: 0;padding: 10px 0 10px 0!important;width: 100%!important;top: 50%;bottom: auto!important;margin-top: -5px!important;}#tabb-cont-0, #tabb-cont-1{position:absolute}#tabb-cont-0{left:0;}#tabb-cont-1{right:0;}
  7. I've changed the code so that it now looks like this: $app->match('/auth/callback', function (Request $request) use ($app, $googleService) {// This was a callback request from google, get the token$googleService->requestAccessToken($request->get('code'));// Send a request with it$user = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);if (substr($user['email'],-11)==='@domain.com') { $host = 'localhost';$dbname = 'xxxxxxx';$username = 'root';$password = 'xxxxxxxxxxxx';$con = new PDO("mysql:host={$host};dbname={$dbname}", $username, $password); // assumes you're using the MySQL database $sql = 'SELECT COUNT(*) AS count FROM users WHERE email = :email';try {$stmt = $con->prepare($sql);$stmt->bindValue(':email', $user['email']);$stmt->execute();$result = $stmt->fetchAll();if ($result[0]['count'] > 0) {// User Exist$user['logged_in_date'] = date('Y-m-d');$app['session']->set('userinfo', $user);$log = new employeeUserLoggedinLog();$log->setEmail($user['email']);$log->setDate(time());$log->save();} else {$message = Swift_Message::newInstance()->setSubject('Alert :: unauthorized login')->setFrom(array('alert@domain.com' => 'robot'))->setTo(array('admin@domain.com'))->setBody(sprintf("The following ex-employee [%s] tried to login from IP [%s]", $user['email'], $request->getClientIp()));$app['mailer']->send($message);}} catch (Exception $ex) {Propel::log($e->getMessage(), Propel::LOG_ERR);throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);} } else {$message = Swift_Message::newInstance()->setSubject('Alert :: unauthorized login')->setFrom(array('alert@domain.com' => 'robot'))->setTo(array('admin@domain.com'))->setBody(sprintf("The following email [%s] tried to login from IP [%s]", $user['email'], $request->getClientIp()));$app['mailer']->send($message);}return $app->redirect('/');}); And now it works perfectly, I just thought I'd post that incase anybody else needed help with it in the future
  8. I'm not sure why this isn't working. I've tried to add 'check if user is in database' function to Google login. The login worked before I add the db check. I've gone through the error logs and no errors are being thrown but when I try to go in I just get returned to the login page. If somebody isn't authorised to log in then they will be returned to the login page but should see the site if they are permitted. I've got this: $app->match('/auth/callback', function (Request $request) use ($app, $googleService) { // This was a callback request from google, get the token $googleService->requestAccessToken($request->get('code')); // Send a request with it $user = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); if (substr($user['email'],-11)==='@domain.com') {function findPkSimple($key, $con) {$sql = 'SELECT COUNT(*) AS count FROM users WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetchAll(); if ($result[0]["count"] > 0) { // User Exist $user['logged_in_date'] = date('Y-m-d'); $app['session']->set('userinfo', $user); $log = new employeeUserLoggedinLog(); $log->setEmail($user['email']); $log->setDate(time()); $log->save(); } else { $message = Swift_Message::newInstance() ->setSubject('Alert :: unauthorized login') ->setFrom(array('alert@domain.com' => 'robot')) ->setTo(array('adim@domain.com')) ->setBody(sprintf("The following email [%s] tried to login from IP [%s]", $user['email'], $request->getClientIp())); $app['mailer']->send($message); } } catch (Exception $ex) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);}} } else { $message = Swift_Message::newInstance() ->setSubject('Alert :: unauthorized login') ->setFrom(array('alert@domain.com' => 'robot')) ->setTo(array('adim@domain.com')) ->setBody(sprintf("The following email [%s] tried to login from IP [%s]", $user['email'], $request->getClientIp())); $app['mailer']->send($message); } return $app->redirect('/');});
  9. Only one query per database table is made but there's a 'filterBy' function for every field. For example here's the one for names and email addresses. public function filterByName($name = null, $comparison = null) { if (null === $comparison) { if (is_array($name)) { $comparison = Criteria::IN; } elseif (preg_match('/[%*]/', $name)) { $name = str_replace('*', '%', $name); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(CustomerContactTableMap::NAME, $name, $comparison); } and public function filterByEmail($email = null, $comparison = null) { if (null === $comparison) { if (is_array($email)) { $comparison = Criteria::IN; } elseif (preg_match('/[%*]/', $email)) { $email = str_replace('*', '%', $email); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(CustomerContactTableMap::EMAIL, $email, $comparison); }
  10. I wonder if somebody could help me please, I'm new to Symphony and am working on a site that's been built using Silex. I want to add an 'order by' option to database results. I've got a page that has lots of information and I want the user to be able to choose the order it's sorted by, for example if they click on name it sorts the results via name, if they click email address is sorts by that etc. I've spent a few weeks trying to get this to work but haven't got anywhere so would be grateful for any help. In the query file (php) there's lots of 'filterBy' functions. filterByEmail, filterByName for example, but I don't know if this is right or if it is how to call it from within the twig file. Thanks in advance for any help.
  11. I commented that out, but it didn't work I understand what you're saying and agree but this is an intranet site and you need to be logged in to see it and you can only see the page with the button on if you're an administrator so it's more of a token security measure that my boss wants. I added an onClick event and changed don't to do not and now it works.
  12. I'm trying to create a pop up box that asks for a password but I can't seem to get it to work. I've got this <SCRIPT>function passWord() {var testV = 1;var pass1 = prompt('Please Enter Your Password',' ');while (testV < 3) {if (!pass1) history.go(-1);if (pass1.toLowerCase() == "password") {window.open('/resources_admin');break;} testV+=1;var pass1 = prompt('Access Denied - Sorry you don't have access to this page','Password');}if (pass1.toLowerCase()!="password" & testV ==3) history.go(-1);return " ";} </SCRIPT> With the button looking like this <a class="btn btn-restricted" id="passWord">Protected Access</a> I've not getting any errors at all but the popup isn't working either. I've checked and popups isn't disabled either.
  13. Sorry to be so dumb but how would I do that?
  14. Thanks, I'm pretty new to all of this so am not sure how to do it, do you know of any examples that might help
  15. I've been asked to add extra security to our site. We're using Google to login people in and currently this is the security we have: $googleService = $serviceFactory->createService('google', $credentials, $storage, array('userinfo_email', 'userinfo_profile'));$app->get('/login', function () use ($app, $googleService) {if($app['session']->get('userinfo')) {return new RedirectResponse('/');}return $app['twig']->render('login.twig', array('login_url' => $googleService->getAuthorizationUri()->__toString(),'user' => $app['session']->get('userinfo'),));}); 
and $app->match('/auth/callback', function (Request $request) use ($app, $googleService) {// This was a callback request from google, get the token$googleService->requestAccessToken($request->get('code'));// Send a request with it$user = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);if (substr($user['email'],-11)==='@domain.com' || $user['email']==='web@anotherdomain.com') {$user['logged_in_date'] = date('Y-m-d');$app['session']->set('userinfo', $user);$log = new UserLoggedinLog();$log->setEmail($user['email']);$log->setDate(time());$log->save();} else {$message = Swift_Message::newInstance()->setSubject('Site :: unauthorized login')->setFrom(array('server@domain.com' => 'robot'))->setTo(array('admin@domain.com','web@domain.com'))->setBody(sprintf("The following email [%s] tried to login from IP [%s]", $user['email'], $request->getClientIp()));$app['mailer']->send($message);}return $app->redirect('/');}); Is there a way to set the email addresses/users that can log in? So if a member of staff leaves they can be prevent from logging in immediately? 

I've built a database table with all of the 'allowed' users in it but I didn't know if there was a way of getting Google login to check that and then only allow somebody if they're in the database?
  16. I'm trying to change the value when the date changes so that when the form is sent it has the chosen date. At the moment although it appears the date changes (from the users point of view) when I look at the source code the date hasn't changed.
  17. I changed it to this: <script>function dateTo(){var x=document.getElementById("form_date_to");x.value=x.value.new Date();}function dateFrom(){var x=document.getElementById("form_date_from");x.value=x.value.new Date();}</script> but as soon as I add the JavaScript in the date selector stops working. The value of the date fields stays the same regardless so it's still not changing ti. The form now looks like this: <form method="post" id="report_filter"> <div class="form-group"><label for="form_date_from" class="required control-label">Date from</label><input type="text" id="form_date_from" name="form[date_from]" required="required" onchange="dateFrom()" 0=" " class="form-control" value="22/07/14" ></div><div class="form-group"><label for="form_date_to" class="required control-label">Date to</label><input type="text" id="form_date_to" name="form[date_to]" required="required" onchange="dateTo()" 0=" " class="form-control" value="28/07/14" ></div><input type="hidden" id="form__token" name="form[_token]" class="form-control" value="67f70a9bac24a6c4167beae497fea635cbd27d74" > <div class="form-group"> <button class="btn btn-default" onSubmit="return validate_form()"><i class="glyphicon glyphicon-search"></i> Filter</button> </div> </form> There's also this function for validating the form: function validate_form(){ var f = document.getElementById('form_date_from').value; var t = document.getElementById('form_date_to').value; var fAlert = "Please enter a from date."; var tAlert = "Please enter a to date."; var em; if (!f.value) { alert (fAlert); return false; } if (!t.value) { alert (tAlert); return false; } return true; }
  18. I don't know about the server memory, how would I find that out?
  19. Both the live and dev server have the sae version on php (5.4) and should be identical. I agree it does sound like a path issue though but as I say they're identical and it works on the dev server
  20. Sorry I don't think I'm being very clear. When this works a pdf is generated from an html page and then emailed to the person who placed the order. On the test site this worked no problems, but now that it's on the live site it's creating the pdf but the images aren't being displayed in the pdf, if you look at the attached file in my previous post you'll see what I mean. The images aren't there when I view it on or offline
  21. It generates the pdf but when I moved it to the live site is stopped showing the images in the pdf. The displayed okay on the dev site. I've attached a screen shot of the two pdf's, the top one is from the live site and the other is from the dev site.
  22. I'm using it on an intranet site to create receipts of orders placed.
  23. I've used this to create a pdf: https://github.com/KnpLabs/KnpSnappyBundle I tested it on a dev server and it worked perfectly but when I transferred it to the live site the images. I've tried using png's and jpg's (as I know there's an issue with gifs) as well as relative, absolute and full paths but nothing I do seems to work. I've attached screen shots of both the live and test sites so you can see what I get.
  24. Thank you, I added this to the code and now it works: public function getDeliveryDates() { $ops = $this->getPhysicalOrderProducts(); $dates = array(); foreach ($ops as $op) { $date = clone $this->getPostDate(); $date->add(new DateInterval('P'.$op->getDeliveryTime().'M')); $dates[] = $date; } return $dates; }
  25. It's being called from a twig file (I'm using Silex) but the code is: {% for op in products %} <li>{{ entry.getDeliveryDate|date("d/m/Y") }}</li> {% endfor %}
×
×
  • Create New...