Search Results

Search found 468 results on 19 pages for 'substr'.

Page 3/19 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Coredump in Multithreading Application in RHEL-5(Help Required)

    - by Chinnu
    I am working on multi-threading application it is dumping frequently.I could not able to analyaze the core.The core is showing like this Core was generated by `thread-process '. Program terminated with signal 6, Aborted. 0 0x00000038f4e30045 in raise () from /lib64/libc.so.6 (gdb) where 0 0x00000038f4e30045 in raise () from /lib64/libc.so.6 1 0x00000038f4e31ae0 in abort () from /lib64/libc.so.6 2 0x00000038f4e681bb in __libc_message () from /lib64/libc.so.6 3 0x00000038f4e72b96 in free () from /lib64/libc.so.6 4 0x000000000046a137 in std::string::substr () 5 0x000000000042c549 in std::operator<< , std::allocator () 6 0x000000000042cc1d in std::operator<< , std::allocator () 7 0x000000000046b069 in std::string::substr () 8 0x000000000046c866 in std::string::substr () 9 0x0000000000431062 in std::operator<< , std::allocator () 10 0x00000038f5a062e7 in start_thread () from /lib64/libpthread.so.0 11 0x00000038f4ece3bd in clone () from /lib64/libc.so.6

    Read the article

  • Is there a way to tell Drupal not to cache a specific page?

    - by TechplexEngineer
    I have a custom php page that processes a feed of images and makes albums out of it. However whenever i add pictures to my feed, the Drupal page doesn't change until I clear the caches. Is there a way to tell Drupal not to cache that specific page? Thanks, Blake Edit: Drupal v6.15 Not exactly sure what you mean oswald, team2648.com/media is hte page. I used the php interpreter module. Here is the php code: <?php //////// CODE by Pikori Web Designs - pikori.org /////////// //////// Please do not remove this title, /////////// //////// feel free to modify or copy this software /////////// $feedURL = 'http://picasaweb.google.com/data/feed/base/user/Techplex.Engineer?alt=rss&kind=album&hl=en_US'; $photoNodeNum = 4; $galleryTitle = 'Breakaway Pictures'; $year = '2011'; ?> <?php /////////////// DO NOT EDIT ANYTHING BELOW THIS LINE ////////////////// $album = $_GET['album']; if($album != ""){ //GENERATE PICTURES $feedURL= "http://".$album."&kind=photo&hl=en_US"; $feedURL = str_replace("entry","feed",$feedURL); $sxml = simplexml_load_file($feedURL); $column = 0; $pix_count = count($sxml->channel->item); //print '<h2>'.$sxml->channel->title.'</h2>'; print '<table cellspacing="0" cellpadding="0" style="font-size:10pt" width="100%"><tr>'; for($i = 0; $i < $pix_count; $i++) { print '<td align="center">'; $entry = $sxml->channel->item[$i]; $picture_url = $entry->enclosure['url']; $time = $entry->pubDate; $time_ln = strlen($time)-14; $time = substr($time,0,$time_ln); $description = $entry->description; $tn_beg = strpos($description, "src="); $tn_end = strpos($description, "alt="); $tn_length = $tn_end - $tn_beg; $tn = substr($description, $tn_beg, $tn_length); $tn_small = str_replace("s288","s128",$tn); $picture_url = $tn; $picture_beg = strpos($picture_url,"http:"); $picture_len = strlen($picture_url)-7; $picture_url = substr($tn, $picture_beg, $picture_len); $picture_url = str_replace("s288","s640",$picture_url); print '<a rel="lightbox[group]" href="'.$picture_url.'">'; print '<img '.$tn_small.' style="border:1px solid #02293a"><br>'; print '</a></td> '; if($column == 4){ print '</tr><tr>'; $column = 0;} else $column++; } print '</table>'; print '<br><center><a href="media">Return to album</a></center>'; } else { //GENERATE ALBUMS $sxml = simplexml_load_file($feedURL); $column = 0; $album_count = count($sxml->channel->item); //print '<h2>'.$galleryTitle.'</h2>'; print '<table cellspacing="0" cellpadding="0" style="font-size:10pt" width="100%"><tr>'; for($i = 0; $i < $album_count; $i++) { $entry = $sxml->channel->item[$i]; $time = $entry->pubDate; $time_ln = strlen($time)-14; $time = substr($time,0,$time_ln); $description = $entry->description; $tn_beg = strpos($description, "src="); $tn_end = strpos($description, "alt="); $tn_length = $tn_end - $tn_beg; $tn = substr($description, $tn_beg, $tn_length); $albumrss = $entry->guid; $albumrsscount = strlen($albumrss) - 7; $albumrss = substr($albumrss, 7, $albumrsscount); $search = strstr($time, $year); if($search != FALSE || $year == ''){ print '<td valign="top">'; print '<a href="/node/'.$photoNodeNum.'?album='.$albumrss.'">'; print '<center><img '.$tn.' style="border:3px double #cccccc"><br>'; print $entry->title.'<br>'.$time.'</center>'; print '</a><br></td> '; if($column == 3){ print '</tr><tr>'; $column = 0; } else { $column++; } } } print '</table>'; } ?>

    Read the article

  • Windows desktop gadget RSS Feed colour coding items

    - by padjo
    I have a desktop gadget that pulls RSS Feeds from a website. The Feed contains information about issues - ie. Priority, Time, Description. The Feed items are displayed on the desktop - however I need to colour code them according to their priority ie 1 = red etc. using the substr function - is there a better way to do this using JavaScript / HTML? At the moment I've hacked together this - but is there a more elegant solution? if (feed.item.description.substr(10,1) == "1") { document.write "<a href colour="red"" + item + ">"; else if (feed.item.description.substr(10,1) == "2") { document.write "<a href colour="yellow"" + item + ">"; else { document.write "<a href colour="green"" + item + ">";

    Read the article

  • How can I give a color to imagecolorallocate?

    - by Roman
    I have a PHP variable which contains information about color. For example $text_color = "ff90f3". Now I want to give this color to imagecolorallocate. The imagecolorallocate works like that: imagecolorallocate($im, 0xFF, 0xFF, 0xFF); So, I am trying to do the following: $r_bg = bin2hex("0x".substr($text_color,0,2)); $g_bg = bin2hex("0x".substr($text_color,2,2)); $b_bg = bin2hex("0x".substr($text_color,4,2)); $bg_col = imagecolorallocate($image, $r_bg, $g_bg, $b_bg); It does not work. Why? I try it also without bin2hex, it also did not work. Can anybody help me with that?

    Read the article

  • Javascript is freezing the browser when running this code

    - by user1420493
    I am trying to get the value of a text input and check if there is any links in it and then take those links and make them into tags. But when I run this code, something is going wrong and it completely freezes the page. Basically, I want it to check for "http://" and if that exists, to keep on adding to the substr length until the end of the string/link. Is there a better way to do this? // the id "post" could possibly say: "Hey, check this out! http://facebook.com" // I'd like it to just get that link and that's all I need help with, just to get the // value of that entire string/link. var x = document.getElementById("post"); var m = x.value.indexOf("http://"); var a = 0; var q = m; if (m != -1) { while (x.value.substr(q, 1) != " ") { var h = x.value.substr(m, a); q++; } }

    Read the article

  • Byte manipulation in PHP

    - by Michael Angstadt
    In PHP, if you have a variable with binary data, how do you get specific bytes from the data? For example, if I have some data that is 30 bytes long, how do I get the first 8 bytes? Right now, I'm treating it like a string, using the substr() function: $data = //... $first8Bytes = substr($data, 0, 8); Is it safe to use substr with binary data? Or are there other functions that I should be using? Thanks.

    Read the article

  • Do you play Sudoku ?

    - by Gilles Haro
    Did you know that 11gR2 database could solve a Sudoku puzzle with a single query and, most of the time, and this in less than a second ? The following query shows you how ! Simply pass a flattened Sudoku grid to it a get the result instantaneously ! col "Solution" format a9 col "Problem" format a9 with Iteration( initialSudoku, Step, EmptyPosition ) as ( select initialSudoku, InitialSudoku, instr( InitialSudoku, '-' )        from ( select '--64----2--7-35--1--58-----27---3--4---------4--2---96-----27--7--58-6--3----18--' InitialSudoku from dual )    union all    select initialSudoku        , substr( Step, 1, EmptyPosition - 1 ) || OneDigit || substr( Step, EmptyPosition + 1 )         , instr( Step, '-', EmptyPosition + 1 )      from Iteration         , ( select to_char( rownum ) OneDigit from dual connect by rownum <= 9 ) OneDigit     where EmptyPosition > 0       and not exists          ( select null              from ( select rownum IsPossible from dual connect by rownum <= 9 )             where OneDigit = substr( Step, trunc( ( EmptyPosition - 1 ) / 9 ) * 9 + IsPossible, 1 )   -- One line must contain the 1-9 digits                or OneDigit = substr( Step, mod( EmptyPosition - 1, 9 ) - 8 + IsPossible * 9, 1 )      -- One row must contain the 1-9 digits                or OneDigit = substr( Step, mod( trunc( ( EmptyPosition - 1 ) / 3 ), 3 ) * 3           -- One square must contain the 1-9 digits                            + trunc( ( EmptyPosition - 1 ) / 27 ) * 27 + IsPossible                            + trunc( ( IsPossible - 1 ) / 3 ) * 6 , 1 )          ) ) select initialSudoku "Problem", Step "Solution"    from Iteration  where EmptyPosition = 0 ;   The Magic thing behind this is called Recursive Subquery Factoring. The Oracle documentation gives the following definition: If a subquery_factoring_clause refers to its own query_name in the subquery that defines it, then the subquery_factoring_clause is said to be recursive. A recursive subquery_factoring_clause must contain two query blocks: the first is the anchor member and the second is the recursive member. The anchor member must appear before the recursive member, and it cannot reference query_name. The anchor member can be composed of one or more query blocks combined by the set operators: UNION ALL, UNION, INTERSECT or MINUS. The recursive member must follow the anchor member and must reference query_name exactly once. You must combine the recursive member with the anchor member using the UNION ALL set operator. This new feature is a replacement of this old Hierarchical Query feature that exists in Oracle since the days of Aladdin (well, at least, release 2 of the database in 1977). Everyone remembers the old syntax : select empno, ename, job, mgr, level      from   emp      start with mgr is null      connect by prior empno = mgr; that could/should be rewritten (but not as often as it should) as withT_Emp (empno, name, level) as        ( select empno, ename, job, mgr, level             from   emp             start with mgr is null             connect by prior empno = mgr        ) select * from   T_Emp; which uses the "with" syntax, whose main advantage is to clarify the readability of the query. Although very efficient, this syntax had the disadvantage of being a Non-Ansi Sql Syntax. Ansi-Sql version of Hierarchical Query is called Recursive Subquery Factoring. As of 11gR2, Oracle got compliant with Ansi Sql and introduced Recursive Subquery Factoring. It is basically an extension of the "With" clause that enables recursion. Now, the new syntax for the query would be with T_Emp (empno, name, job, mgr, hierlevel) as       ( select E.empno, E.ename, E.job, E.mgr, 1 from emp E where E.mgr is null         union all         select E.empno, E.ename, E.job, E.mgr, T.hierlevel + 1from emp E                                                                                                            join T_Emp T on ( E.mgr = T.empno ) ) select * from   T_Emp; The anchor member is a replacement for the "start with" The recursive member is processed through iterations. It joins the Source table (EMP) with the result from the Recursive Query itself (T_Emp) Each iteration works with the results of all its preceding iterations.     Iteration 1 works on the results of the first query     Iteration 2 works on the results of Iteration 1 and first query     Iteration 3 works on the results of Iteration 1, Iteration 2 and first query. So, knowing that, the Sudoku query it self-explaining; The anchor member contains the "Problem" : The Initial Sudoku and the Position of the first "hole" in the grid. The recursive member tries to replace the considered hole with any of the 9 digit that would satisfy the 3 rules of sudoku Recursion progress through the grid until it is complete.   Another example :  Fibonaccy Numbers :  un = (un-1) + (un-2) with Fib (u1, u2, depth) as   (select 1, 1, 1 from dual    union all    select u1+u2, u1, depth+1 from Fib where depth<10) select u1 from Fib; Conclusion Oracle brings here a new feature (which, to be honest, already existed on other concurrent systems) and extends the power of the database to new boundaries. It’s now up to developers to try and test it and find more useful application than solving puzzles… But still, solving a Sudoku in less time it takes to say it remains impressive… Interesting links: You might be interested by the following links which cover different aspects of this feature Oracle Documentation Lucas Jellema 's Blog Fibonaci Numbers

    Read the article

  • How to display values from another website to an new html page?

    - by user3098728
    How to display the value in a new html file from different website? This an example field of values that need to display into new html file and I want to display the said values in the input box (Contract ID) of this page JSFiddle. I have 2 JS code that would display that values, but unfortunately its not working and I dont know how to display that value in html input box. Please help me. Thank you I want to display the said value in this input box: Here the JS file to read the values: function scanLapVerification() { try { var page_title = "Title"; var el = getElement(document, "class", "view-operator-verification-title", ""); if (!el || el.length == 0) return; if (el[0].innerText != page_title) return; var page_title = ''; var el = getElement(document, "class", "workflowActivityDetailPanel", ""); if (el && el.length > 0) { var eltr = getElement(el[0], "tag", "tr", ""); if (eltr && eltr.length > 0) { //Read Contract ID var contractId = { CI: { id: null } }; var con_id = null; for (var i = 0; i < eltr.length; i++) { tr_text = eltr[i].innerText; if (tr_text.substr(0, "Contract ID".length) == "Contract ID") con_id = "CI"; if (con_id && tr_text.substr(0, "Contract ID".length) == "Contract ID") { contractId[con_id].id = tr_text.substr("Contract ID".length + 1, tr_text.length - "Contract ID".length - 1); } } var contract_id = contractId.CI.id; return { content: "cid_check", con_id: con_id }; } return { status: "KO" }; } catch (e) { alert("Exception: scanLapVerification\n" + e.Description); return { status: "KO", message: e }; } }; And here's the 2nd JS that display to a new html page: function scanLapVerification() { chrome.tabs.sendRequest(tabLapVerification, { method: "scanLapVerification" }, function (response) { msgbox("receiveResponse: scanLapVerification " + jsonToString(response, "JSON")); //maintaining state in the background if (response.data.content == "cid_check") { //Popup window features var popupWindow = null; var name; var width = 550; var height = 200; var left = parseInt((screen.availWidth / 2) - (width / 2)); var top = parseInt((screen.availHeight / 2) - (height / 2)); var windowFeatures = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; //Input new address with popup window if (confirm("Does the client has new address?") == true) { popupWindow = window.open('/htmlname.htm', "title", windowFeatures + encodeURIComponent(response.data.contract_id)); popupWindow.focus(); } else { name = ""; } }); }

    Read the article

  • wm_concat function and small characer buffer

    - by Ruslan
    Hi, i have select like: select substr(account,1,4), currency, amount, module,count(*) quan, wm_concat(id) ids from all_transactions group by substr(account,1,4), currency, amount, module But sometimes COUNT(*) is more then 600. In that case i get: 'ORA-06502: PL/SQL: : character string buffer too small' Is there any way out to keep wm_concat(id) for all records? Because excluding this function for entries with big COUNT(*) is the way out.

    Read the article

  • Increase efficiency of a loop with jQuery

    - by Pez Cuckow
    I have a game coded in jQuery where bots are moved around the screen. The below code is a loop that runs every 20ms, currently if you have over 15 bots you start to notice the browser lagging (simply because of all the advanced collision detection going on). Is there any way to reduce the lag, can I make it any more efficient? P.s. sorrry for just posting a block of code, I can't see a way to make my point clear enough without! $.playground().registerCallback(function(){ //Movement Loop if(!pause) { for (var i in bots) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd var self = $('#b' + i); var current = bots[i]; if(bots[i][5]==1) { var xspeed = 0, yspeed = 0; if(current[1]==0) { yspeed = -D_SPEED; } else if(current[1]==1) { xspeed = D_SPEED; } else if(current[1]==2) { yspeed = D_SPEED; } else if(current[1]==3) { xspeed = -D_SPEED; } var x = current[2] + xspeed; var y = current[3] + yspeed; var z = current[3] + 120; if(current[2]>0&&x>PLAYGROUND_WIDTH||current[2]<0&&x<-GRID_SIZE|| current[3]>0&&y>PLAYGROUND_HEIGHT||current[3]<0&&y<-GRID_SIZE) { remove_bot(i, self); } else { if(current[7]!=current[1]) { self.setAnimation(colors[current[0]][current[1]]); bots[i][7] = current[1]; } if(self.css({"left": ""+(x)+"px", "top": ""+(y)+"px", "z-index": z})) { bots[i][2] = x; bots[i][3] = y; bots[i][4] = z; bots[i][8]++; } } } } $("#debug").html(dump(arrows)); $(".bot").each(function(){ var b_id = $(this).attr("id").substr(1); var collision = false; var c_bot = bots[b_id]; var b_x = c_bot[2]; var b_y = c_bot[3]; var b_d = c_bot[1]; $(this).collision(".arrow,#arrows").each(function(){ //Many thanks to Selim Arsever for this fix! var a_id = $(this).attr("id").substr(1); var piece = arrows[a_id]; var a_v = piece[0]; if(a_v==1) { var a_x = piece[2]; var a_y = piece[3]; var d_x = b_x-a_x; var d_y = b_y-a_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd bots[b_id][7] = c_bot[1]; bots[b_id][1] = piece[1]; collision = true; } } }); if(!collision) { $(this).collision(".wall,#level").each(function(){ var w_id = $(this).attr("id").substr(1); var piece = pieces[w_id]; var w_x = piece[1]; var w_y = piece[2]; d_x = b_x-w_x; d_y = b_y-w_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=27&&d_y<=28) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-12&&d_x<=-11&&d_y>=21&&d_y<=22) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-9&&d_y<=-8) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=20&&d_y<=21) { kill_bot(b_id); collision = true; } //22 // 21 }); } if(!collision&&c_bot[8]>GRID_MOVE) { $(this).collision(".spawn,#level").each(function(){ var s_id = $(this).attr("id").substr(1); var piece = pieces[s_id]; var s_x = piece[1]; var s_y = piece[2]; d_x = b_x-s_x; d_y = b_y-s_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=19&&d_y<=20) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-14&&d_x<=-13&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-11&&d_y<=-10) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //22 // 21*/ }); } if(!collision) { $(this).collision(".exit,#level").each(function(){ var e_id = $(this).attr("id").substr(1); var piece = pieces[e_id]; var e_x = piece[1]; var e_y = piece[2]; d_x = b_x-e_x; d_y = b_y-e_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { current_bots++; bots[b_id] = false; $("#current_bots").html(current_bots); $("#b" + b_id).setAnimation(exit[2], function(node){$(node).fadeOut(200)}); } }); } if(!collision) { $(this).collision(".bot,#level").each(function(){ var bd_id = $(this).attr("id").substr(1); if(bd_id!=b_id) { var piece = bots[bd_id]; var bd_x = piece[2]; var bd_y = piece[3]; d_x = b_x-bd_x; d_y = b_y-bd_y; if(d_x>=0&&d_x<=2&&d_y>=0&&d_y<=2) { kill_bot(b_id); kill_bot(bd_id); collision = true; } } }); } }); } }, REFRESH_RATE); Many thanks,

    Read the article

  • Increase efficiency of a loop with jQuery and GameQuery

    - by Pez Cuckow
    I have a game coded in jQuery where bots are moved around the screen. The below code is a loop that runs every 20ms, currently if you have over 15 bots you start to notice the browser lagging (simply because of all the advanced collision detection going on). Is there any way to reduce the lag, can I make it any more efficient? P.s. sorrry for just posting a block of code, I can't see a way to make my point clear enough without! $.playground().registerCallback(function(){ //Movement Loop if(!pause) { for (var i in bots) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd var self = $('#b' + i); var current = bots[i]; if(bots[i][5]==1) { var xspeed = 0, yspeed = 0; if(current[1]==0) { yspeed = -D_SPEED; } else if(current[1]==1) { xspeed = D_SPEED; } else if(current[1]==2) { yspeed = D_SPEED; } else if(current[1]==3) { xspeed = -D_SPEED; } var x = current[2] + xspeed; var y = current[3] + yspeed; var z = current[3] + 120; if(current[2]>0&&x>PLAYGROUND_WIDTH||current[2]<0&&x<-GRID_SIZE|| current[3]>0&&y>PLAYGROUND_HEIGHT||current[3]<0&&y<-GRID_SIZE) { remove_bot(i, self); } else { if(current[7]!=current[1]) { self.setAnimation(colors[current[0]][current[1]]); bots[i][7] = current[1]; } if(self.css({"left": ""+(x)+"px", "top": ""+(y)+"px", "z-index": z})) { bots[i][2] = x; bots[i][3] = y; bots[i][4] = z; bots[i][8]++; } } } } $("#debug").html(dump(arrows)); $(".bot").each(function(){ var b_id = $(this).attr("id").substr(1); var collision = false; var c_bot = bots[b_id]; var b_x = c_bot[2]; var b_y = c_bot[3]; var b_d = c_bot[1]; $(this).collision(".arrow,#arrows").each(function(){ //Many thanks to Selim Arsever for this fix! var a_id = $(this).attr("id").substr(1); var piece = arrows[a_id]; var a_v = piece[0]; if(a_v==1) { var a_x = piece[2]; var a_y = piece[3]; var d_x = b_x-a_x; var d_y = b_y-a_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd bots[b_id][7] = c_bot[1]; bots[b_id][1] = piece[1]; collision = true; } } }); if(!collision) { $(this).collision(".wall,#level").each(function(){ var w_id = $(this).attr("id").substr(1); var piece = pieces[w_id]; var w_x = piece[1]; var w_y = piece[2]; d_x = b_x-w_x; d_y = b_y-w_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=27&&d_y<=28) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-12&&d_x<=-11&&d_y>=21&&d_y<=22) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-9&&d_y<=-8) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=20&&d_y<=21) { kill_bot(b_id); collision = true; } //22 // 21 }); } if(!collision&&c_bot[8]>GRID_MOVE) { $(this).collision(".spawn,#level").each(function(){ var s_id = $(this).attr("id").substr(1); var piece = pieces[s_id]; var s_x = piece[1]; var s_y = piece[2]; d_x = b_x-s_x; d_y = b_y-s_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=19&&d_y<=20) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-14&&d_x<=-13&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-11&&d_y<=-10) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //22 // 21*/ }); } if(!collision) { $(this).collision(".exit,#level").each(function(){ var e_id = $(this).attr("id").substr(1); var piece = pieces[e_id]; var e_x = piece[1]; var e_y = piece[2]; d_x = b_x-e_x; d_y = b_y-e_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { current_bots++; bots[b_id] = false; $("#current_bots").html(current_bots); $("#b" + b_id).setAnimation(exit[2], function(node){$(node).fadeOut(200)}); } }); } if(!collision) { $(this).collision(".bot,#level").each(function(){ var bd_id = $(this).attr("id").substr(1); if(bd_id!=b_id) { var piece = bots[bd_id]; var bd_x = piece[2]; var bd_y = piece[3]; d_x = b_x-bd_x; d_y = b_y-bd_y; if(d_x>=0&&d_x<=2&&d_y>=0&&d_y<=2) { kill_bot(b_id); kill_bot(bd_id); collision = true; } } }); } }); } }, REFRESH_RATE); Many thanks,

    Read the article

  • Text Obfuscation using base64_encode()

    - by user271619
    I'm playing around with encrypt/decrypt coding in php. Interesting stuff! However, I'm coming across some issues involving what text gets encrypted into. Here's 2 functions that encrypt and decrypt a string. It uses an Encryption Key, which I set as something obscure. I actually got this from a php book. I modified it slightly, but not to change it's main goal. I created a small example below that anyone can test. But, I notice that some characters show up as the "encrypted" string. Characters like "=" and "+". Sometimes I pass this encrypted string via the url. Which may not quite make it to my receiving scripts. I'm guessing the browser does something to the string if certain characters are seen. I'm really only guessing. is there another function I can use to ensure the browser doesn't touch the string? or does anyone know enough php bas64_encode() to disallow certain characters from being used? I'm really not going to expect the latter as a possibility. But, I'm sure there's a work-around. enjoy the code, whomever needs it! define('ENCRYPTION_KEY', "sjjx6a"); function encrypt($string) { $result = ''; for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr(ENCRYPTION_KEY, ($i % strlen(ENCRYPTION_KEY))-1, 1); $char = chr(ord($char)+ord($keychar)); $result.=$char; } return base64_encode($result)."/".rand(); } function decrypt($string){ $exploded = explode("/",$string); $string = $exploded[0]; $result = ''; $string = base64_decode($string); for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr(ENCRYPTION_KEY, ($i % strlen(ENCRYPTION_KEY))-1, 1); $char = chr(ord($char)-ord($keychar)); $result.=$char; } return $result; } echo $encrypted = encrypt("reaplussign.jpg"); echo "<br>"; echo decrypt($encrypted);

    Read the article

  • Will this only allow certain extensions?

    - by Dr Hydralisk
    I found this snippet that says will only allow certain file types. Will it work and could someone bypass it to upload what ever file type they want? And could someone explain the substr part, i don't get how it works.. <?php function CheckExt($filename, $ext) { $name = strtolower($filename); if(substr($name, strlen($name) -3, 3) == $ext) return true; else return false; } ?>

    Read the article

  • Why PHP Error: Call to a member function set_prefix() on a non-object

    - by Rebol Tutorial
    I got this error Fatal error: Call to a member function set_prefix() on a non-object in /home/reboltutorial/reboltutorial.com/wp-settings.php on line 254 line 254 contains: $prefix = $wpdb->set_prefix($table_prefix); // set up global tables This occurs if I try to call index_wordpress() instead of calling these two lines define('WP_USE_THEMES', true); require('./wp-blog-header.php'); so this doesn't work: <?php function index_wordpress() { define('WP_USE_THEMES', true); require('./wp-blog-header.php'); } ?> <?php if(!function_exists('apache_request_headers')) { function apache_request_headers() { $headers = array(); foreach($_SERVER as $key => $value) { if(substr($key, 0, 5) == 'HTTP_') { $headers[str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))))] = $value; } } return $headers; } } function getCurrentPageUrl() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } $a = apache_request_headers(); $pos = strrpos($a["User-Agent"], "REBOL"); if ($pos === false) { index_wordpress(); } else { if ($_SERVER['REMOTE_ADDR'] != "69.163.203.14") { $command= './cgi-bin/index.cgi '. '"' . getCurrentPageUrl() . '"'; echo system($command); } else { index_wordpress(); } } ?> while this works: <?php if(!function_exists('apache_request_headers')) { function apache_request_headers() { $headers = array(); foreach($_SERVER as $key => $value) { if(substr($key, 0, 5) == 'HTTP_') { $headers[str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))))] = $value; } } return $headers; } } function getCurrentPageUrl() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } $a = apache_request_headers(); $pos = strrpos($a["User-Agent"], "REBOL"); if ($pos === false) { define('WP_USE_THEMES', true); require('./wp-blog-header.php'); } else { if ($_SERVER['REMOTE_ADDR'] != "69.163.203.14") { $command= './cgi-bin/index.cgi '. '"' . getCurrentPageUrl() . '"'; echo system($command); } else { define('WP_USE_THEMES', true); require('./wp-blog-header.php'); } } ?>

    Read the article

  • php add hours to date output wrong result

    - by i need help
    Basically what I want to do is to send an email to follow up on order placed in 3 hours later. What I try to do is to get the current date (up to hours level), then compare with the orderdate+ 3 hours, to see whether it match. Example orderdate: 2010-06-12 18, after add 3 hours should become 2010-06-12 21 However, after add hour, the final result sometimes become bigger, sometimes become smaller... something wrong. $now= date('Y-m-d H'); echo $now . "<br>"; ... ... while ($data = mysql_fetch_array ($result)) { $orderid = $data['orderid']; $orddate = $data['orddate']; $corddate= date('Y-m-d H:i:s', $orddate); $year = substr ($corddate, 0, 4); $month = substr ($corddate, 5, 2); $day = substr ($corddate, 8, 2); $hour = substr ($corddate, 11, 2); $actualorderdate= $year . "-" . $month . "-" . $day . " " . $hour; $new_time = mktime ($hour+3, 0, 0, $month, $day, $year); $year = date ('Y', $new_time); $month = date ('m', $new_time); $day= date ('d', $new_time); $hour= date ('h', $new_time); $xhourslater= $year . "-" . $month . "-" . $day . " " . $hour; echo "actualorderdate: ". $actualorderdate. " xhourslater: " . $xhourslater. "<br>"; if($now==$xhourslater) { echo "now is 3 hours later" . "<br>"; //send email follow up, then update status as sent, in order not to resend anytime in the 3rd hour. } }

    Read the article

  • Replace first Letter in a field Oracle

    - by Stanley
    Hi Guys I have this Table I need to replace the First Letter in ACCT_NAME with the First Name of ACCT_SHORT_NAME. Records like the Higliighted(RAFFMAN) should not be changed. I have tried: select acct_name, ACCT_SHORT_NAME,replace(acct_name, substr(acct_name, 1, 1), ACCT_SHORT_NAME) from tbaadm.gam where schm_type = 'TDA' and rcre_user_id = 'SYSTEM' and substr(acct_name,2,1) = ' ' I am getting: This means that am Picking the whole value in ACCT_SHORT_NAME. WHat is the best way to do what am trying to do?

    Read the article

  • Convert Bitmap Files into JPEG using the GD library in PHP

    - by Daniel P
    I have been trying to figure out a way to convert bitmap files into a JPEG using the GD library in PHP. I have tried numerous implementations but nothing seems to work. I have tried to tell my client that they should not use Bitmap files but he insists and quite frankly does not comprehend enough about computers to convert them to JPG on his own. I can not use ImageMagick on this server and I need a pure GD solution. Thank you in advance for any and all help. EDIT: The bitmap images that are being used are 16-bit and that is where the problem is occurring. I have this function that I have working .... kinda: function ImageCreateFromBMP($filename) { if (! $f1 = fopen($filename,"rb")) return FALSE; $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); if ($FILE['file_type'] != 19778) return FALSE; $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); $BMP['decal'] = 4-(4*$BMP['decal']); if ($BMP['decal'] == 4) $BMP['decal'] = 0; $PALETTE = array(); if ($BMP['colors'] < 16777216 && $BMP['colors'] != 65536) { $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4)); } $IMG = fread($f1,$BMP['size_bitmap']); $VIDE = chr(0); $res = imagecreatetruecolor($BMP['width'],$BMP['height']); $P = 0; $Y = $BMP['height']-1; while ($Y >= 0) { $X=0; while ($X < $BMP['width']) { if ($BMP['bits_per_pixel'] == 24) $COLOR = unpack("V",substr($IMG,$P,3).$VIDE); elseif ($BMP['bits_per_pixel'] == 16) { $COLOR = unpack("v",substr($IMG,$P,2)); $blue = ($COLOR[1] & 0x001f) << 3; $green = ($COLOR[1] & 0x07e0) >> 3; $red = ($COLOR[1] & 0xf800) >> 8; $COLOR[1] = $red * 65536 + $green * 256 + $blue; } elseif ($BMP['bits_per_pixel'] == 8) { $COLOR = unpack("n",$VIDE.substr($IMG,$P,1)); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 4) { $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 1) { $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } else return FALSE; imagesetpixel($res,$X,$Y,$COLOR[1]); $X++; $P += $BMP['bytes_per_pixel']; } $Y--; $P+=$BMP['decal']; } fclose($f1); return $res; } The resulting image is this: If you look at the image on the left hand side you can see that the resulting image is not correctly lined up. The little sliver belongs on the right hand side. Where is the code going wrong? The problem is occurring in the 16-bit else-if. Thank you again for all the help.

    Read the article

  • jQuery urlencode/decode patch help

    - by jeerose
    Hi Gang, I'm using this jQuery urlencode and urldecode plugin - very simple and easy to use but it doesn't, in its original form, remove + from the string. The one comment on the home page suggests a patch but I don't know how to implement it. Can anyone help me out? The Page: http://www.digitalbart.com/jquery-and-urlencode/ //URL Encode/Decode $.extend({URLEncode:function(c){var o='';var x=0;c=c.toString(); var r=/(^[a-zA-Z0-9_.]*)/; while(x<c.length){var m=r.exec(c.substr(x)); if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length; }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16); o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}, URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/; while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){ b=parseInt(m[1].substr(1),16); t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;} }); The proposed Patch: function dummy_url_decode(url) { // fixed -- + char decodes to space char var o = url; var binVal, t, b; var r = /(%[^%]{2}|\+)/; while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') { if (m[1] == '+') { t = ' '; } else { b = parseInt(m[1].substr(1), 16); t = String.fromCharCode(b); } o = o.replace(m[1], t); } return o; } Thanks!

    Read the article

  • C++ Set Erase Entry Question

    - by Wallace
    Hi. I encountered a problem here. I'm using C++ multiset. This is the test file. Score: 3-1 Ben Steven Score: 1-0 Ben Score: 0-0 Score: 1-1 Cole Score: 1-2 Ben I'm using while loop and ifstream (fin1) to read in from the test file above. multiset<string, less<string> > myset; while(!fin1.eof()) { fin1 >> scoreName; if(scoreName == "Score:") { //calculates number of matches played } else { goalCheck = scoreName.substr(1,1); if(goalCheck == "-") { string lGoal, rGoal; lGoal = scoreName.substr(0,1); rGoal = scoreName.substr(2,1); int leftGoal, rightGoal; leftGoal = atoi(lGoal.c_str()); rightGoal = atoi(rGoal.c_str()); if(leftGoal > rightGoal) //if team wins { //some computations } else if(leftGoal < rightGoal) //if team loses { //computations } else if(leftGoal == rightGoal) //if team draws { //computations } else { myset.insert(myset.begin(), scoreName); } } } I'm inserting all names into myset (regardless of wins/loses/draws) in my last else statement. But I only require the names of those matches who won/draw. Those names whose matches lost will not be included in myset. In the test file above, there's only one match that lost (1-2) and I wanted to remove "Ben". How can I do that? I tried to use myset.erase(), but I'm not sure how to get it point to Ben and remove it from myset. Any help is much appreciated. Thanks.

    Read the article

  • i want the ruby code of the php code i have given inside , please help me out

    - by Arpit Vaishnav
    <?php // amcharts.com export to image utility // set image type (gif/png/jpeg) $imgtype = 'jpeg'; // set image quality (from 0 to 100, not applicable to gif) $imgquality = 100; // get data from $_POST or $_GET ? $data = &$_POST; // get image dimensions $width = (int) $data['width']; $height = (int) $data['height']; // create image object $img = imagecreatetruecolor($width, $height); // populate image with pixels for ($y = 0; $y < $height; $y++) { // innitialize $x = 0; // get row data $row = explode(',', $data['r'.$y]); // place row pixels $cnt = sizeof($row); for ($r = 0; $r < $cnt; $r++) { // get pixel(s) data $pixel = explode(':', $row[$r]); // get color $pixel[0] = str_pad($pixel[0], 6, '0', STR_PAD_LEFT); $cr = hexdec(substr($pixel[0], 0, 2)); $cg = hexdec(substr($pixel[0], 2, 2)); $cb = hexdec(substr($pixel[0], 4, 2)); // allocate color $color = imagecolorallocate($img, $cr, $cg, $cb); // place repeating pixels $repeat = isset($pixel[1]) ? (int) $pixel[1] : 1; for ($c = 0; $c < $repeat; $c++) { // place pixel imagesetpixel($img, $x, $y, $color); // iterate column $x++; } } } // set proper content type header('Content-type: image/'.$imgtype); header('Content-Disposition: attachment; filename="chart.'.$imgtype.'"'); // stream image $function = 'image'.$imgtype; if ($imgtype == 'gif') { $function($img); } else { $function($img, null, $imgquality); } // destroy imagedestroy($img); ?

    Read the article

  • jQuery - Could use a little help with a content loader

    - by Kenny Bones
    Hi, I'm not very elite when it comes to JavaScript, especially the syntax. So I'm trying to learn. And in this process I'm trying to implement a content loader that basically removes all content from a div and inserts content from another div from a different document. I've tried to do this on this site: www.matkalenderen.no - Check the butt ugly link there. See what happens? I've taken the example from this site: http://nettuts.s3.cdn.plus.org/011_jQuerySite/sample/index.html#index But I'm not sure this example actually works the way I think it does. I mean, if the code just wipes out existing content from a div and inserts content from another div, why does the other webpages in this example include doctype and heading etc etc? Wouldn't you just need the div and it's content? Without all the other stuff "around"? Maybe I don't get how this works though. Thought it worked mosly like include really. This is my code however: $(document).ready(function() { var hash = window.location.hash.substr(1); var href = $('#dynloader a').each(function(){ var href = $(this).attr('href'); if(hash==href.substr(0,href.length-5)){ var toLoad = hash+'.html #container'; $('#container').load(toLoad) } }); $('#dynloader a').click(function(){ var toLoad = $(this).attr('href')+' #container'; $('#container').hide('fast',loadcontainer); $('#load').remove(); $('#wrapper').append('<span id="load">LOADING...</span>'); $('#load').fadeIn('normal'); window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); function loadcontainer() { $('#container').load(toLoad,'',showNewcontainer()) } function showNewcontainer() { $('#container').show('normal',hideLoader()); } function hideLoader() { $('#load').fadeOut('normal'); } return false; }); });

    Read the article

  • Coredump in Multithreading Application in RHEL-5

    - by Chinnu
    I am working on multi-threading application it is dumping frequently.I could not able to analyaze the core.The core is showing like this Core was generated by 'thread-process'. Program terminated with signal 6, Aborted. #0 0x00000038f4e30045 in raise () from /lib64/libc.so.6 (gdb) where #0 0x00000038f4e30045 in raise () from /lib64/libc.so.6 #1 0x00000038f4e31ae0 in abort () from /lib64/libc.so.6 #2 0x00000038f4e681bb in __libc_message () from /lib64/libc.so.6 #3 0x00000038f4e72b96 in free () from /lib64/libc.so.6 #4 0x000000000046a137 in std::string::substr () #5 0x000000000042c549 in std::operator<< <char, std::char_traits<char>, std::allocator<char> > () #6 0x000000000042cc1d in std::operator<< <char, std::char_traits<char>, std::allocator<char> > () #7 0x000000000046b069 in std::string::substr () #8 0x000000000046c866 in std::string::substr () #9 0x0000000000431062 in std::operator<< <char, std::char_traits<char>, std::allocator<char> > () #10 0x00000038f5a062e7 in start_thread () from /lib64/libpthread.so.0 #11 0x00000038f4ece3bd in clone () from /lib64/libc.so.6

    Read the article

  • please convert this PHP code in ruby

    - by Arpit Vaishnav
    <?php // amcharts.com export to image utility // set image type (gif/png/jpeg) $imgtype = 'jpeg'; // set image quality (from 0 to 100, not applicable to gif) $imgquality = 100; // get data from $_POST or $_GET ? $data = &$_POST; // get image dimensions $width = (int) $data['width']; $height = (int) $data['height']; // create image object $img = imagecreatetruecolor($width, $height); // populate image with pixels for ($y = 0; $y < $height; $y++) { // innitialize $x = 0; // get row data $row = explode(',', $data['r'.$y]); // place row pixels $cnt = sizeof($row); for ($r = 0; $r < $cnt; $r++) { // get pixel(s) data $pixel = explode(':', $row[$r]); // get color $pixel[0] = str_pad($pixel[0], 6, '0', STR_PAD_LEFT); $cr = hexdec(substr($pixel[0], 0, 2)); $cg = hexdec(substr($pixel[0], 2, 2)); $cb = hexdec(substr($pixel[0], 4, 2)); // allocate color $color = imagecolorallocate($img, $cr, $cg, $cb); // place repeating pixels $repeat = isset($pixel[1]) ? (int) $pixel[1] : 1; for ($c = 0; $c < $repeat; $c++) { // place pixel imagesetpixel($img, $x, $y, $color); // iterate column $x++; } } } // set proper content type header('Content-type: image/'.$imgtype); header('Content-Disposition: attachment; filename="chart.'.$imgtype.'"'); // stream image $function = 'image'.$imgtype; if ($imgtype == 'gif') { $function($img); } else { $function($img, null, $imgquality); } // destroy imagedestroy($img); ?

    Read the article

  • Primefaces push encoding

    - by kalaoke
    I use primefaces push to write a message in a p:notificationBar. if i push a message with specials characters (like russians char), I've got '?' in my message. How can I fix this problem ? Thanks for your help. (config : primefaces 3.4 and jsf2. All my html pages are utf8 encoding). Here is my view code : <p:notificationBar id="bar" widgetVar="pushNotifBar" position="bottom" style="z-index: 3;border: 8px outset #AB1700;width: 97%;background: none repeat scroll 0 0 #CA837D;"> <h:form prependId="false"> <p:commandButton icon="ui-icon-close" title="#{messages['gen.close']}" styleClass="ui-notificationbar-close" type="button" onclick="pushNotifBar.hide();"/> </h:form> <h:panelGrid columns="1" style="width: 100%; text-align: center;"> <h:outputText id="pushNotifSummary" value="#{growlBean.summary}" style="font-size:36px;text-align:center;"/> <h:outputText id="pushNotifDetail" value="#{growlBean.detail}" style="font-size: 20px; float: left;" /> </h:panelGrid> </p:notificationBar> <p:socket onMessage="handleMessage" channel="/notifications"/> <script type="text/javascript"> function handleMessage(data) { var substr = data.split(' %% '); $('#pushNotifSummary').html(substr[0]); $('#pushNotifDetail').html(substr[1]); pushNotifBar.show(); } </script> and my Bean code : public void send() { PushContext pushContext = PushContextFactory.getDefault().getPushContext(); String var = summary + " %% " + detail; pushContext.push("/notifications", var);

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >