Jump to content

Ivan Ivković

Members
  • Posts

    139
  • Joined

  • Last visited

    Never

Everything posted by Ivan Ivković

  1. http://pixpresso.mycyberlove.com/ This is the URL. Code in dynamic_src: <?php $p = realpath(dirname(__FILE__)); define('ROOT_SITE_PATH', $p); include(ROOT_SITE_PATH . '/includes/functions.php'); # Global functions. include(ROOT_SITE_PATH. '/includes/init.php'); # Page constants, includes for the app 'n stuff. $init = new Init(); unset($init); if(isset($_GET['file'])){ $file_ext = substr(strrchr($_GET['file'],'.'),1); $file_name = preg_replace('/\.[^.]*$/', '', $_GET['file']); switch(strtolower($file_ext)){ case 'css': header('Content-Type: text/css; charset: UTF-8;'); $file = DIR_STYLES . $file_name . '.php'; if(is_file($file)){ include($file); } break; case 'js': header('Content-Type: application/x-javascript; charset: UTF-8;'); $file = DIR_SCRIPTS . $file_name . '.php'; if(is_file($file)){ include($file); } break; } }else{ die(header('Location: ' . WEB_PATH)); } Code to call it: <script type="text/javascript" src="http://pixpresso.mycyberlove.com/dynamic_src.php?file=nav_scroll.js"></script> <link rel="stylesheet" type="text/css" src="http://pixpresso.mycyberlove.com/dynamic_src.php?file=popups.css"/> Output working! But browser doesn't read it as CSS for some reason? Output in http://pixpresso.mycyberlove.com/dynamic_src.php?file=main.css : body{ margin: 0; text-align: center; overflow-x: hidden; background-color: #f7f7f7; background: url(/src/images/image_background.png); background-repeat: repeat; } *{ font-family: "tahoma",lucida grande,verdana,arial,sans-serif; color: #666; text-shadow: white 0 1px 0; } h4, h5, h6{ font-weight: 300; padding: 0; margin: 0; } img{ border: 0; } .element{ /*background-color: white; border: 1px solid #dadada;*/ /*-moz-box-shadow: 0 0 7px #333; -webkit-box-shadow: 0 0 7px#333; box-shadow: 0 0 7px #333; */ } a{ text-decoration: none; } #background{ position: fixed; top: -50px; left: -50px; width: 150%; height: 150%; background-color: #000; z-index: 99998; display: none; } #background2{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #222; z-index: 99980; display: none; } .popup{ position: fixed; left: 50%; top: 50%; background-color: #e5e5e5; z-index: 99999; -moz-box-shadow: 0 0 80px #000; -webkit-box-shadow: 0 0 80px #000; box-shadow: 0 0 80px #333; display: none; border-radius: 4px; } .data{ display: none; } .hidden{ position: absolute; left: -10000px; width: 0; padding: 0; margin: 0; } #warning{ position: relative; top: 90px; border: 1px solid #999; left: 4px; width: 99%; padding: 10px 0px; color: #666; background-color: #e6e6e6; } #warning2{ position: relative; top: 290px; border: 1px solid #555; left: 4px; width: 99%; padding: 10px 0px; color: #444; background-color: #ccc; } #wrapper{ clear: both; width: 98%; position: relative; left: 1%; top: 90px; } .cleaner{ height: 0px; clear: both; } .fl{ float: left; } .fr{ float: right; } .pic_link{ text-transform: none; cursor: pointer !important; } .pointer{ cursor: pointer !important; } .pic_link:hover{ text-transform: none; } img{ border: 0; } .spacer10{ display: block; height: 10px; clear: both; } .spacer20{ display: block; height: 20px; clear: both; } .spacer30{ display: block; height: 30px; clear: both; } .no_decoration{ text-decoration: none !important; cursor: text !important; } .underline{ text-decoration: underline !important; } .image_link{ cursor: pointer; border: 0; } .user_pic{ border: 1px solid #d9d9d9 !important; } So for some reason browser won't render CSS and JS? Why is this the case? Info is being outputted, is something wrong with my html tags or something?
  2. All my template class does is recieve the data ( template -> any_attribute ) and loads the template (loadTemplate). It does not change the variable/mysqli result object in any way, why should it? Damn strange. <?php class Template{ public $vars; private $registry; public function __construct($registry){ $this -> registry = $registry; } public function __set($index, $value){ $this -> vars[$index] = $value; } public function loadTemplate($tpl){ $path = $this -> registry -> router -> dir_path . '/' . $tpl . '.php'; if(file_exists($path) == false){ throw new Exception('Template not found in '. $path); return false; } if(!empty($this -> vars)){ foreach($this -> vars as $key => $value){ $$key = $value; } } include($path); } } I do not see the problem here. Do you maybe? About sub-optimal. Yea I know.. :/ Nothing's perfect I guess.
  3. Hey guys I solved the error. However, I still don't understand it. May be a bug in the MySQLi extension itself.. Instead of: $fetch = $pic -> fetchAlbumPics($user_id, $city_id, $cat_id); if($fetch !== false){ $this -> registry -> template -> result = $fetch; } I've put. $fetch = $pic -> fetchAlbumPics($user_id, $city_id, $cat_id); if($fetch !== false){ $this -> registry -> template -> result = $pic -> fetchAlbumPics($user_id, $city_id, $cat_id); } Still, don't know why this was the problem.
  4. I'm from Balkan.. xD Anyways I'll keep you updated on the error if I find the answer. I'll get back to it now. (was doing some other things)
  5. Ok I can no longer give you sample outputs, I must continue to work on this. If there's anyone who already guesses what's the problem/solution, thank you.
  6. Please look at the page again. Explains it all. The BOM issue you're seeing is just because I'm outputting sample data from controller/model files.
  7. There. This is the live link btw. http://pixpresso.mycyberlove.com/album/list_/26/0/51295 And the problem is NOT in the query, the query has been tested.
  8. This is the method from the picture model. public function fetchAlbumPics($user_id, $city_id, $cat_id){ if($cat_id == 0 && $user_id != 0 && $city_id != 0) $query = 'SELECT * FROM sc_pics WHERE user_id="' . $user_id . '" AND city_id="' . $city_id . '"'; if($cat_id != 0 && $city_id != 0 && $user_id != 0) $query = 'SELECT * FROM sc_pics WHERE user_id="' . $user_id . '" AND city_id="' . $city_id . '" AND cat_id="' . $cat_id . '"'; $result = $this -> db -> query($query); $return = $result -> num_rows ? $result : false; return $return; } This is where it's being called. $fetch = $pic -> fetchAlbumPics($user_id, $city_id, $cat_id); if($fetch !== false){ $this -> registry -> template -> pics = $fetch; } This is the view where it's being outputted: <?php if(isset($pics)){ echo $pics -> num_rows; while($fetch = $pics -> fetch_array()){ $description = $fetch['description'] == '' ? 'No Description' : $fetch['description']; ?> <div class="element item"> <a class="item_link" href="/photo/view/<?php echo $fetch['pic_id'] ?>"> <img class="img" src="/thumb.php?pic=content/pics/<?php echo $fetch['user_id'] . $fetch['src'] ?>&h=250&w=250"/> </a> </div> <?php } } ?> Result: mysql_num_rows returns 3 results, the script outputs only 2 results/pictures. SQL query in PHPMYADMIN outputs 3 results... This loops only 2 results, I don't know why. There's no bug inside the loop, since I've tried only echoing number 0 instead of outputting information. Only outputs 2 times. I don't know how to fix this for now. And the problem is NOT in the query, the query has been tested.
  9. Should I attach pagename.css for each page or should I include all css rules in one css file? My logic is if you load the huge css file every time, the page will be slower, and if you split them by purpose (for each page or widget), you'll get a faster output. Is that true?
  10. Turns out it's not. done variable does not really get created after the animate function. Is there a better solution?
  11. Sometimes I can't actually control the order of functions jQuery or javascript. Maybe just my lack of understanding javascript. Like if I put function1(); function2(); it will not execute function1, then function2, but both at the same time. This is how I handle that: function loadAjaxPopup(width, height, widget, action, criteria){ mg_lft = - width / 2; mg_top = - height / 2; $('#background').animate({opacity: '0.45'}, 0).fadeIn(200); $('body:not(#background)').append('<div class="popup"></div>'); var done = true; if(done == true){ $('.popup').slideDown(200); $('.popup').animate({ height: height + 'px', marginTop : mg_top + 'px' }, 200); done2 = true; if(done2 == true){ $('.popup').animate({ width: width + 'px', marginLeft : mg_lft + 'px' },200 ); done3 = true; if(done3 == true){ $.get( '/ajax/' + widget + '/' + action + '/' + criteria, function(data){ $('.popup').append(data); $('.data').fadeIn(200); }, 'html' ); } } } } Is this a good or a bad way to handle my problem? What do you think?
  12. "Implement a search engine in this kind of table". What exactly do you want? A search engine does not search the HTML table. A search engine is not implement in your table. A search FORM can be implemented in your table, and it depends what you want your search engine (the backend code) search from the DATABASE and where to output it.
  13. The template file. <?php include(WIDGETS . 'html_head.php'); ?> <link rel="stylesheet" type="text/css" href="/src/styles/masonry.css"/> </script> </head> <body id="<?php echo $this -> registry -> router -> page ?>"> <div id="background"></div> <?php include(WIDGETS . 'navigation.php'); ?> <div id="container" style="position: absolute; top: 80px;"> <?php $result = $this -> registry -> db -> query('SELECT * FROM sc_pics ORDER BY pic_id DESC LIMIT 20'); $world = new WorldDatabase($this -> registry -> db); $cat = new Categories($this -> registry -> db); include('includes/fbconfig.php'); while($fetch = $result -> fetch_array()){ ?> <div class="element item" id="pic_<?php echo $fetch['pic_id'] ?>"> <?php echo '<img src="/thumb.php?pic=content/pics/' . $fetch['user_id'] . $fetch['src'] . '&h=200&w=210"/>'; ?> </div> <?php } ?> </div> <input type="hidden" id="last_id"/> <script> $('#last_id').attr('value', $('.item:last').attr('id')); </script> <script type="text/javascript" src="/src/scripts/masonry.js"></script> <script type="text/javascript"> var container = document.getElementById('container'); var wall = new Masonry( container, {isFitWidth: true }); var boxMaker = {}; boxMaker.makeBoxes = function(last_id){ var boxes = []; var request = $.ajax({ url: '/ajax/infinite_scroll/', type: 'POST', data: { last_id : last_id }, dataType: 'json' }); request.fail(function(jqXHR, textStatus){ alert( "Request failed: " + textStatus); }); request.done(function(data){ ndata = data; return data; }); if(!ndata.error){ $('#last_id').val('pic_' + ndata.pic_id); alert('NEW ID: pic_' + ndata.pic_id + ',' + ' NEW LAST ID: ' + $('#last_id').val()); var box = document.createElement('div'); text = document.createElement('img'); text.src = '/thumb.php?pic=content/pics/' + ndata.user_id + ndata.src + '&h=200&w=210"'; box.className = 'element item masonry-brick'; box.id = 'pic_' + ndata.pic_id; box.appendChild( text ); boxes.push( box ); }else{ if(ndata.error != 'complete'){ alert(ndata.error); } } return boxes; }; window.onscroll = function(){ if(($(document).height() - $(window).height() - $(document).scrollTop()) < 300){ var container = document.getElementById('container'); var wall = new Masonry( container, {isFitWidth: true }); var last_id = $('#last_id').val(); alert('Start LAST ID: ' + last_id ); var boxes = boxMaker.makeBoxes(last_id); for (var i=0; i < boxes.length; i++) { container.appendChild( boxes[i] ); } wall.appended( boxes ); } } </script> </body> </html> This is an infinite scroll I'm doing and I store my last picture ID in an input type hidden element for the AJAX -> PHP to know from which ID to continue outputting pictures. However, this last_id does not function properly and the app makes double pictures. I put up alert boxes for testing purposes, hope they help you too. PHP side: public function infinite_scroll(){ header("Content-Type: application/json"); if(!empty($_POST)){ if(isset($_POST['last_id'])){ $pic_id = end(explode('_', $_POST['last_id'])); $security = new Security($this -> registry -> db); $pic = new Picture($this -> registry -> db); if($security -> checkNum($pic_id)){ $items = $pic -> getInfiniteScrollData($pic_id); if($items !== false ){ foreach($items as $key => $value){ $data[$key] = $value; } }else{ $data = array( 'error' => 'complete' ); } }else{ $data = array( 'error' => 'Invalid input!' ); } } } echo json_encode($data); } URL : http://pixpresso.mycyberlove.com Pls help.
  14. It wasn't whitespace, it was encoding in UTF8, now it's without BOM. Thank you! You've beeen very helpful, everything is in order now.
  15. What's a net tab? Ok I'll go check.
  16. My PHP on /ajax/infinite_scroll/ public function infinite_scroll(){ header("Content-Type: application/json"); $data = array( 'key' => 'value', 'key2' => 'value2' ); echo json_encode($data); }
  17. K I understand. Now I have some other problem. My new code: var request = $.ajax({ url: '/ajax/infinite_scroll/', type: 'POST', data: { last_id : $('.item:last').attr('id') }, dataType: 'json' }); request.done(function(data){ alert(data); }); request.fail(function(jqXHR, textStatus){ alert( "Request failed: " + textStatus); }); URL exists, $('.item:last').attr('id') value exists, I don't know what's wrong. You can test it on pixpresso.mycyberlove.com if you'd like. I get "PARSERERROR" error.
  18. Thanks man! How can I get that data in javascript?
×
×
  • 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.