Jump to content

sspoke

Members
  • Posts

    282
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

sspoke's Achievements

Member

Member (2/5)

0

Reputation

  1. I just started working with my first .htaccess RewriteRule because when submitting a facebook app, it must end with either a trailing slash or be a dynamic URL. My domain already is used for another project so I put my app into a sub-directory so it looks like this http://www.example.com/app/index2.html I'm trying to convert it to be in this format http://www.example.com/app/fbapp/ I can't use app's sub-directory as index.html or index.php which is already used outside of a facebook with Google Ads, since Google Ads are illegal to be used on facebook, I created a copy of the index.html called index2.html without any Google ads on it. I started messing around with .htaccess and I got it semi-working but in Google Chrome it seems to detect the URL as being a folder and starts loading the stylesheets and javascript scripts from the fake virtual directory assuming that fbapp is a directory when it should be app/file.xxx instead of app/fbapp/file.xxx Here is what I got so far I still don't understand how to use Rewrite Condionals but from my understanding if the RewriteCond is triggered it will run the line right under it, otherwise it will skip it somehow and go to the third line which works fine as long as it's not a script/image/stylesheet/etc... RewriteEngine on RewriteCond $1 !^(favicon\.ico|favicon\.png|robots\.txt|css|js) [NC] RewriteRule ^(.*)$ $1 [E=BASE:%1] RewriteRule ^fbapp index2.html [E=BASE:%1]
  2. Hey guys I want to sort the messages by poster_time instead of the usual id incrementing as I have restored a database with auto incrementing id's and very old messages show up on top i'd like to be able to sort them by poster_time to fix that problem. I've attempted to fix this myself but I don't want to lose any functionality, here is my attempt. SELECT t.id_topic FROM {db_prefix}topics AS t' . ($context['sort_by'] === 'last_poster' ? ' INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)' : (in_array($context['sort_by'], array('starter', 'subject')) ? ' INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)' : '')) . ($context['sort_by'] === 'starter' ? ' LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' : '') . ($context['sort_by'] === 'last_poster' ? ' LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)' : '') . ' WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . ' LIMIT {int:start}, {int:maxindex}', to this for testing purposes SELECT t.id_topic FROM topics AS t INNER JOIN messages AS ml ON (ml.id_msg = t.id_last_msg) INNER JOIN messages AS mf ON (mf.id_msg = t.id_first_msg) LEFT JOIN members AS memf ON (memf.id_member = mf.id_member) LEFT JOIN members AS meml ON (meml.id_member = ml.id_member) WHERE t.id_board = 1 ORDER BY ml.poster_time DESC LIMIT 0, 500 Using the code above I've figured out I need ml.poster_time DESC how do I bundle it up with the code at the very top. Here the structures boards structure topics structure messages structure $topic_ids = array(); $context['topics'] = array(); // Sequential pages are often not optimized, so we add an additional query. $pre_query = $start > 0; if ($pre_query && $maxindex > 0) { $request = $smcFunc['db_query']('', ' SELECT t.id_topic FROM {db_prefix}topics AS t' . ($context['sort_by'] === 'last_poster' ? ' INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)' : (in_array($context['sort_by'], array('starter', 'subject')) ? ' INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)' : '')) . ($context['sort_by'] === 'starter' ? ' LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' : '') . ($context['sort_by'] === 'last_poster' ? ' LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)' : '') . ' WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . ' LIMIT {int:start}, {int:maxindex}', array( 'current_board' => $board, 'current_member' => $user_info['id'], 'is_approved' => 1, 'id_member_guest' => 0, 'start' => $start, 'maxindex' => $maxindex, ) ); $topic_ids = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) $topic_ids[] = $row['id_topic']; } // Grab the appropriate topic information... if (!$pre_query || !empty($topic_ids)) { // For search engine effectiveness we'll link guests differently. $context['pageindex_multiplier'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; $result = $smcFunc['db_query']('substring', ' SELECT t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, ' . ($user_info['is_guest'] ? '0' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from, t.id_last_msg, t.approved, t.unapproved_posts, t.is_solved, ml.poster_time AS last_poster_time, ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, ml.poster_name AS last_member_name, ml.id_member AS last_id_member, IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg, mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon, mf.poster_name AS first_member_name, mf.id_member AS first_id_member, IFNULL(memf.real_name, mf.poster_name) AS first_display_name, SUBSTRING(ml.body, 1, 385) AS last_body, SUBSTRING(mf.body, 1, 385) AS first_body, ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg) INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member) LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' . ($user_info['is_guest'] ? '' : ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = {int:current_board} AND lmr.id_member = {int:current_member})'). ' WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' ORDER BY ' . ($pre_query ? 'FIND_IN_SET(t.id_topic, {string:find_set_topics})' : (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . ' LIMIT ' . ($pre_query ? '' : '{int:start}, ') . '{int:maxindex}', array( 'current_board' => $board, 'current_member' => $user_info['id'], 'topic_list' => $topic_ids, 'is_approved' => 1, 'find_set_topics' => implode(',', $topic_ids), 'start' => $start, 'maxindex' => $maxindex, ) ); Thanks guys i've been suffering with this for a whole week now.
  3. This is probably the wrong section, hell wrong forum but it's worth a try as SMF forums are abandoned this from MessageIndex.php function MessageIndex() which shows the list of topics on the current board you are viewing each topics table (threads) can hold many messages table (replies) each message has a poster_time which is the epoch unix timestamp Now the problem is it's not properly getting sorted. The topics (threads) are sorted by the primary ID and are bumped to top if messages (replies) which contain also a primary id are highest. Pretty much what i'm trying to say messages or topics doesn't matter the highest primary id wins the spotlight. Now I am restoring my database I did some edits to it so it would be compatible with SMF 2.0. Some threads are as old as 1997 yet the last thread posted is on top of the page.. So my question is how do I convert the below SQL queries so I can sort by the timestamp and not the highest Id. ( I know this won't be a problem if you run the forum properly but if I restored a database what can I do now ). Thank you. function MessageIndex() { $topic_ids = array(); $context['topics'] = array(); // Sequential pages are often not optimized, so we add an additional query. $pre_query = $start > 0; if ($pre_query && $maxindex > 0) { $request = $smcFunc['db_query']('', ' SELECT t.id_topic FROM {db_prefix}topics AS t' . ($context['sort_by'] === 'last_poster' ? ' INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)' : (in_array($context['sort_by'], array('starter', 'subject')) ? ' INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)' : '')) . ($context['sort_by'] === 'starter' ? ' LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' : '') . ($context['sort_by'] === 'last_poster' ? ' LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)' : '') . ' WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . ' LIMIT {int:start}, {int:maxindex}', array( 'current_board' => $board, 'current_member' => $user_info['id'], 'is_approved' => 1, 'id_member_guest' => 0, 'start' => $start, 'maxindex' => $maxindex, ) ); $topic_ids = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) $topic_ids[] = $row['id_topic']; } // Grab the appropriate topic information... if (!$pre_query || !empty($topic_ids)) { // For search engine effectiveness we'll link guests differently. $context['pageindex_multiplier'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; $result = $smcFunc['db_query']('substring', ' SELECT t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, ' . ($user_info['is_guest'] ? '0' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from, t.id_last_msg, t.approved, t.unapproved_posts, t.is_solved, ml.poster_time AS last_poster_time, ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, ml.poster_name AS last_member_name, ml.id_member AS last_id_member, IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg, mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon, mf.poster_name AS first_member_name, mf.id_member AS first_id_member, IFNULL(memf.real_name, mf.poster_name) AS first_display_name, SUBSTRING(ml.body, 1, 385) AS last_body, SUBSTRING(mf.body, 1, 385) AS first_body, ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg) INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg) LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member) LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' . ($user_info['is_guest'] ? '' : ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = {int:current_board} AND lmr.id_member = {int:current_member})'). ' WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' ORDER BY ' . ($pre_query ? 'FIND_IN_SET(t.id_topic, {string:find_set_topics})' : (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . ' LIMIT ' . ($pre_query ? '' : '{int:start}, ') . '{int:maxindex}', array( 'current_board' => $board, 'current_member' => $user_info['id'], 'topic_list' => $topic_ids, 'is_approved' => 1, 'find_set_topics' => implode(',', $topic_ids), 'start' => $start, 'maxindex' => $maxindex, ) ); // Begin 'printing' the message index for current board. while ($row = $smcFunc['db_fetch_assoc']($result)) { //... } }
  4. nice one abra and also thanks rifts good read
  5. How am i to do this either a php builtin function i am unaware about or something simple with regular expressions replacing I need a way to remove whitespace (tabs,spaces,newlines,etc) and anything else that seperates <> tags such as <td class="subject solvedbg"> <div> <span id="msg_1">blah blah space see <a href="blahblah> </div> </td> to <td class="subject solvedbg"><div><span id="msg_1">blah blah space see<a href="blahblah></div></td> Thank you.
  6. You did mean DELETE u.*, c.*, c2.*, t.* FROM users u LEFT JOIN chats c ON c.userId = $row['id'] LEFT JOIN chats c2 ON c2.randomUserId = $row['id'] LEFT JOIN typing t ON t.id = $row['id'] WHERE u.userId = $row['id'] right? c2.randomUserId not c.randomUserId ?
  7. nevermind solved: tag issue thanks to stackoverflow peeps replaced var N = $('<td><td />').attr('id', 'chattypeorcell').append('or'); to var N = $('<td></td>').attr('id', 'chattypeorcell').append('or');
  8. Thanks fenway you're awesome, very smart man. Works like a charm! Although if a user's userId is already deleted all the other queries fail but i doubt that will happen any other way except if I edit the database by hand.
  9. I'm trying to generate a small part of the page using jquery which is generating in the wrong matter even though the code looks solid. $('#stages').html(""); var stage = $("#stages"); var L = $('<h2></h2>').attr('id', 'startachat').append('Who do you wish to connect to?'); stage.append(L); var k = $('<table></table>').attr('id', 'chattypes'); stage.append(k); var G = $('<tr></tr>'); k.append(G); var m = $('<td></td>'); var s = $('<img />').attr({'src' : 'data/male_off.png', 'alt' : 'Male', 'class' : 'gender', 'id' : 'genderM'}); var N = $('<td><td />').attr('id', 'chattypeorcell').append('or'); var j = $('<td></td>'); var D = $('<img />').attr({'src' : 'data/female_off.png', 'alt' : 'Female', 'class' : 'gender', 'id' : 'genderF'}); var x = $('<td><td />').attr('id', 'chattypeorcell').append('or'); var l = $('<td></td>'); var z = $('<img />').attr({'src' : 'data/any_off.png', 'alt' : 'Anyone', 'class' : 'gender', 'id' : 'genderA'}); G.append(m); m.append(s); G.append(N); G.append(j); j.append(D); G.append(x); G.append(l); l.append(z); the html it generates has way to many "or" table data output <div id="stages"> <h2 id="startachat">Who do you wish to connect to?</h2> <table id="chattypes"> <tbody> <tr> <td><img src="data/male_off.png" alt="Male" class="gender" id="genderM"></td> <td id="chattypeorcell">or</td><td id="chattypeorcell">or</td> <td><img src="data/female_off.png" alt="Female" class="gender" id="genderF"></td> <td id="chattypeorcell">or</td><td id="chattypeorcell">or</td> <td><img src="data/any_off.png" alt="Anyone" class="gender" id="genderA"></td> </tr> </tbody> </table> </div> I want it to generate something similar to this <div id="stages"> <h2 id="startachat">What's your gender?</h2> <table id="chattypes"> <tr> <td id="chattypetextcell"><img src="data/male_off.png" alt="Male" class="gender" id="genderM"/></td> <td id="chattypeorcell">or</td> <td id="chattypevideocell"><img src="data/female_off.png" alt="Female" class="gender" id="genderF"/></td> <td id="chattypeorcell">or</td> <td id="chattypevideocell"><img src="data/any_off.png" alt="Anyone" class="gender" id="genderA"/></td> </tr> </table> </div> thank you for reading
  10. Well problem solved you just have to disable the error page checking in godaddy strangely enough that fixed it.
  11. I've tested it out fine on localhost and it works perfectly. Using swfobject.embedSWF("data/videochat.swf", "flash", 322, 516, "10.0.0", null, null, null, null, function (a) { if (!a.success) { //........ } }); on my domain i've used swfobject.embedSWF("/data/videochat.swf", "flash", 322, 516, "10.0.0", null, null, null, null, function (a) { if (!a.success) { //........ } }); still doesn't work i am confused what the problem is.. I've checked out the file @ http://mydomain.com/data/videochat.swf (it exists and it loads up) I did go with the Linux host and all testing was done on a windows host.. although this is strictly clientside code so i have no idea why that matters Thanks i've been trying to solve this for 7 hours also snapped my neck.
  12. yah what hosting is this anyways?
  13. check all at once. replace $_REQUEST WITH $_POST OR $_GET or leave $_REQUEST to check both if you are unsure. foreach($_REQUEST as $name => $value) { if($value == "") { echo $name." is empty"; } } this supports POSTS/GETS i'm not sure what you are using. you can ofcourse use strlen() to get length of string if it's 0 in size then it's empty.. or even the function empty() although if you are submitting a number 0 is considered empty too.. so up 2 u.
  14. http://phpsysinfo.sourceforge.net/ you can't actually check how much CPU your script is running although you can add a timestamp to start at top of page and a subtract it from a new timestamp reading to get a value how long it took your site to load but it doesn't reflect the cpu usage i guess.. and you can tell that you site loads under a second etc.. blah completely off topic tbh nothing can really do this unless you have remote access of the machines desktop/terminal
  15. DELETE users.*, chats.*, typing.* FROM users u, chats c, typing t WHERE u.userId = $row['id'] AND c.userId = $row['id'] AND c.randomUserId = $row['id'] AND t.id = $row['id'] like that? but some places *could* be already empty like typing/chats. i've looked into LEFT JOIN seems it only joins one other table how can I do 3 at once? To delete data from all 3 tables based on that one row[id] variable
×
×
  • 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.