Search Results

Search found 290 results on 12 pages for 'morgan cheng'.

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

  • How to troubleshoot PHP session file empty issue?

    - by Morgan Cheng
    I have a very simple test page for PHP session. <?php session_start(); if (isset($_SESSIONS['views'])) { $_SESSIONS['views'] = $_SESSIONS['pv'] + 1; } else { $_SESSIONS['views'] = 0; } var_dump($_SESSIONS); ?> After refreshing the page, it always show array 'views' => int 0 The environment is XAMPP 1.7.3. I checked phpInfo(). The session is enabled. Session Support enabled Registered save handlers files user sqlite Registered serializer handlers php php_binary wddx Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 On On When the page is accessed, there is session file sess_lnrk7ttpai8187v9q6iok74p20 created in my "D:\xampp\tmp" folder. But the content is empty. With Firebug, I can see cookies about the session. Cookie PHPSESSID=lnrk7ttpai8187v9q6iok74p20 It seems session data is not flushed to files. Is there any way or direction to trouble shoot this issue? Thanks.

    Read the article

  • Setting ModerationInformation.Status from Approved back to pending removes

    - by Gavin Morgan
    Seeing if anyone else has had this problem and a resolution to it. I have a visual studio sequential workflow on a list (not a library) which does NOT use tasks, the approval process is done through the Approve/Reject OOTB buttons on the list item. The approval is a 2 stage approval, whereby if the 1st stage is completed (via clicking the Approve OOTB button), i reset the ModerationInformation.Status from Approved back to pending then send an email to the 2nd stage approver. My problem is, when i set the the ModerationInformation.Status back to Pending from Approved so there is never an approved version, the Creator loses permissions to view the item, and i get the "cannot find item" error from SharePoint for the person who created the item. The 1st and 2nd level approvers and anyone with approve rights CAN still see the item. Some more background information. the code i am using to update the moderationinformation is I get the properties from the workflow event and get a hook into the listitem properties.Item.ModerationInformation.Status = SPModerationStatusType.Pending; properties.Item.Update(); can anyone help.

    Read the article

  • Google liked drop down menu

    - by Yan Cheng CHEOK
    Hello, whenever we go to Google Page and click on the "more", a menu will be dropped down. I would like to have the following effect on my web site too. May I know which JavaScript library can help me to achieve the similar effect?

    Read the article

  • Is it necessary to "escape" character "<" and ">" for javascript string?

    - by Morgan Cheng
    Sometimes, server side will generate strings to be embedded in inline JavaScript code. For example, if "UserName" should be generated by ASP.NET. Then it looks like. <script> var username = "<%UserName%>"; </script> This is not safe, because a user can have his/her name to be </script><script>alert('bug')</script></script> It is XSS vulnerability. So, basically, the code should be: <script> var username = "<% JavascriptEncode(UserName)%>"; </script> What JavascriptEncode does is to add charater "\" before "/" and "'" and """. So, the output html is like. var username = "<\/scriptalert(\'bug\')<\/script<\/script"; Browser will not interpret "<\/script" as end of script block. So, XSS in avoided. However, there are still "<" and "" there. It is suggested to escape these two characters as well. First of all, I don't believe it is a good idea to change "<" to "&lt;" and "" to "&gt;" here. And, I'm not sure changing "<" to "\<" and "" to "\" is recognizable to all browsers. It seems it is not necessary to do further encoding for "<" and "". Is there any suggestion on this? Thanks.

    Read the article

  • Best Pratice to Implement Secure Remember Me

    - by Yan Cheng CHEOK
    Sometimes, I came across certain web development framework which doesn't provide authentication feature as in Authenication ASP.NET I was wondering what is the security measure needs to be considered, when implementing "Remember Me" login feature, by hand coding? Here are the things I usually did. 1) Store the user name in cookie. The user name are not encrypted. 2) Store a secret key in cookie. The secret key is generated using one way function based on user name. The server will verify secret key against user name, to ensure this user name is not being changed. 3) Use HttpOnly in cookie. http://www.codinghorror.com/blog/2008/08/protecting-your-cookies-httponly.html Any things else I could miss out, which could possible lead a security hole.

    Read the article

  • c# .net change label text

    - by Morgan
    Hello for I trying to use this code but for some reason it doesn't work. Really need help with this. The problem is that the label doesn't change name from "label" when I enter the site. <asp:Label ID="Label1" runat="server" Text= label'></asp:Label> <% Label1.Text = "test"; if (Request.QueryString["ID"] != null) { string test = Request.QueryString["ID"]; Label1.Text = "Du har nu lånat filmen:" + test; } %>

    Read the article

  • char array to LPCTSTR

    - by Yan Cheng CHEOK
    May I know how I can perform the following conversion? // el.strCap is char[50] // InsertItem is expecting TCHAR pointer (LPCTSTR) // How I can perform conversion? // I do not have access in both "list" and "el" source code // Hence, there is no way for me to modify their signature. list.InsertItem(i, el.strCap); And No. I do not want to use WideCharToMultiByte They are too cumbersome to be used.

    Read the article

  • Case Insensitive Ternary Search Tree

    - by Yan Cheng CHEOK
    I had been using Ternary Search Tree for a while, as the data structure to implement a auto complete drop down combo box. Which means, when user type "fo", the drop down combo box will display foo food football The problem is, my current used of Ternary Search Tree is case sensitive. My implementation is as follow. It had been used by real world for around 1++ yeas. Hence, I consider it as quite reliable. My Ternary Search Tree code However, I am looking for a case insensitive Ternary Search Tree, which means, when I type "fo", the drop down combo box will show me foO Food fooTBall Here are some key interface for TST, where I hope the new case insentive TST may have similar interface too. /** * Stores value in the TernarySearchTree. The value may be retrieved using key. * @param key A string that indexes the object to be stored. * @param value The object to be stored in the tree. */ public void put(String key, E value) { getOrCreateNode(key).data = value; } /** * Retrieve the object indexed by key. * @param key A String index. * @return Object The object retrieved from the TernarySearchTree. */ public E get(String key) { TSTNode<E> node = getNode(key); if(node==null) return null; return node.data; } An example of usage is as follow. TSTSearchEngine is using TernarySearchTree as the core backbone. Example usage of Ternary Search Tree // There is stock named microsoft and MICROChip inside stocks ArrayList. TSTSearchEngine<Stock> engine = TSTSearchEngine<Stock>(stocks); // I wish it would return microsoft and MICROCHIP. Currently, it just return microsoft. List<Stock> results = engine.searchAll("micro");

    Read the article

  • Handling Google clientLogin Captcha Example

    - by Yan Cheng CHEOK
    I have a desktop application. I try to perform authentication using http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html However, whenever I get a Captcha challenge, I use a HTTP GET request (I test using web browser) to get the image to present to user. https://www.google.com/accounts/Captcha?ctoken=Y-DrsDJRiWNOP3gR7fq0PAq4Yxvi3UXewu7P7jgAKjk0eZKQ358nbh27-JZ3-nlzXvfKOD3JvZNXwmlRunyz8jPKzqmkOLw2LYb3ZWjg-tE%3A0gMUFttsSH7QwganSJd1aw However, I always get the images : Sorry, we are unable to handle your request at this time. Please try again later. Any idea what I had did wrong? Thanks!

    Read the article

  • Prevent Cross-site request forgery - Never Rely on The SessionID Sent to Your Server in The Cookie H

    - by Yan Cheng CHEOK
    I am reading the tutorial at http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ It states Remember - you must never rely on the sessionID sent to your server in the cookie header ; look only at the sessionID that your GWT app sends explicitly in the payload of messages to your server. Is it use to prevent http://en.wikipedia.org/wiki/Cross-site_request_forgery#Example_and_characteristics With this mythology, is it sufficient enough to prevent to above attack?

    Read the article

  • Custom validation summary

    - by Robert Morgan
    I'm using the UpdateModel method for validation. How do I specify the text for the error messages as they appear in the validation summary? Sorry, I wasn't entirely clear. When I call UpdateModel(), if there is parsing error, for example if a string value is specified for a double field, a "SomeProperty is invalid" error message is automatically added to the ModelState. How do I specify the text for said automatically generated error message? If I implement IDataErrorInfo as suggested, it's error message property gets called for every column, regardless of whether the default binder deems it valid or not. I'd have to reimplement the parse error catching functionality that I get for free with the default binder. Incidentally, the default "SomeProperty is invalid" error messages seem to have mysteriously dissappeared in the RC. A validation summary appears and the relevant fields are highlighted but the text is missing! Any idea why this is? Thanks again and I hope all this waffle makes sense!

    Read the article

  • Make Map Key Sorted According To Insert Sequence

    - by Yan Cheng CHEOK
    Without help from additional container (like vector), is it possible that I can make map's key sorted same sequence as insertion sequence? #include <map> #include <iostream> using namespace std; int main() { map<const char*, int> m; m["c"] = 2; m["b"] = 2; m["a"] = 2; m["d"] = 2; for (map<const char*, int>::iterator begin = m.begin(); begin != m.end(); begin++) { // How can I get the loop sequence same as my insert sequence. // c, b, a, d std::cout << begin->first << std::endl; } getchar(); }

    Read the article

  • javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp] error with java scheduler

    - by Morgan Azhari
    What I'm trying to do is to update my database after a period of time. So I'm using java scheduler and connection pooling. I don't know why but my code only working once. It will print: init success success javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp]. at org.apache.naming.NamingContext.lookup(NamingContext.java:820) at org.apache.naming.NamingContext.lookup(NamingContext.java:168) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:411) at test.Pool.main(Pool.java:25) ---> line 25 is Context envContext = (Context)initialContext.lookup("java:/comp/env"); I don't know why it only works once. I already test it if I didn't running it without java scheduler and it works fine. No error whatsoerver. Don't know why i get this error if I running it using scheduler. Hope someone can help me. My connection pooling code: public class Pool { public DataSource main() { try { InitialContext initialContext = new InitialContext(); Context envContext = (Context)initialContext.lookup("java:/comp/env"); DataSource datasource = new DataSource(); datasource = (DataSource)envContext.lookup("jdbc/test"); return datasource; } catch (Exception ex) { ex.printStackTrace(); } return null; } } my web.xml: <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <listener> <listener-class> package.test.Pool</listener-class> </listener> <resource-ref> <description>DB Connection Pooling</description> <res-ref-name>jdbc/test</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> Context.xml: <?xml version="1.0" encoding="UTF-8"?> <Context path="/project" reloadable="true"> <Resource auth="Container" defaultReadOnly="false" driverClassName="com.mysql.jdbc.Driver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="0" jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer" jmxEnabled="true" logAbandoned="true" maxActive="300" maxIdle="50" maxWait="10000" minEvictableIdleTimeMillis="300000" minIdle="30" name="jdbc/test" password="test" removeAbandoned="true" removeAbandonedTimeout="60" testOnBorrow="true" testOnReturn="false" testWhileIdle="true" timeBetweenEvictionRunsMillis="30000" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/database?noAccessToProcedureBodies=true" username="root" validationInterval="30000" validationQuery="SELECT 1"/> </Context> my java scheduler public class Scheduler extends HttpServlet{ public void init() throws ServletException { System.out.println("init success"); try{ Scheduling_test test = new Scheduling_test(); ScheduledExecutorService executor = Executors.newScheduledThreadPool(100); ScheduledFuture future = executor.scheduleWithFixedDelay(test, 1, 60 ,TimeUnit.SECONDS); }catch(Exception e){ e.printStackTrace(); } } } Schedule_test public class Scheduling_test extends Thread implements Runnable{ public void run(){ Updating updating = new Updating(); updating.run(); } } updating public class Updating{ public void run(){ ResultSet rs = null; PreparedStatement p = null; StringBuilder sb = new StringBuilder(); Pool pool = new Pool(); Connection con = null; DataSource datasource = null; try{ datasource = pool.main(); con=datasource.getConnection(); sb.append("SELECT * FROM database"); p = con.prepareStatement(sb.toString()); rs = p.executeQuery(); rs.close(); con.close(); p.close(); datasource.close(); System.out.println("success"); }catch (Exception e){ e.printStackTrace(); } }

    Read the article

  • @user.posts.where('status = ?', :unfinished).all returns []

    - by Cheng
    By @user.posts, I can see there is a post with :unfinished status. But @user.posts.where('status = ?', :unfinished).all returns an empty array. I've tried to invoke @user.reload first, but it doesn't resolve the problem. (rdb:568) @user.posts [#<Post id: 1, content: "hehe", user_id: 1, created_at: "2010-04-03 06:16:47", updated_at: "2010-04-03 06:16:47", status: "--- :unfinished\n">] (rdb:568) @user.posts.where('status = ?', :unfinished).all []

    Read the article

  • How to troubleshoot memcache set method always fail issue?

    - by Morgan Cheng
    I have XAMPP 1.7.3 installed on Windows 7. The PHP version is 5.3.1. I have successfully installed memcache for win32 from http://www.splinedancer.com/memcached-win32. I got PHP extension php_memcache.dll from http://downloads.php.net/pierre. Restarting apache and checking phpinfo() shows memcache is OK. When I test it with below PHP page. It always fail in set method. <?php $memcache = new Memcache; $memcache->connect('127.0.0.1', 11211) or die ("Could not connect"); $version = $memcache->getVersion(); echo "Server's version: ".$version." \n"; $tmp_object = new stdClass; $tmp_object->str_attr = 'test'; $tmp_object->int_attr = 123; $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); echo "Store data in the cache (data will expire in 10 seconds)\n"; $get_result = $memcache->get('key'); echo "Data from the cache: \n" ?> The set method always return false so it constantly output Server's version: Failed to save data at the server I'm stuck. I don't know which way to trouble shoot this issue. Anybody has any idea about possible direction? Thanks.

    Read the article

  • What Are Basic Tools For A New Project?

    - by Morgan Cheng
    For a long time, I thought that to start a new project we only need 3 basic tools. 1) A Build System (e.g. Maven & CruiseControl) 2) A Version Control System (e.g. CVS & SVN & GIT) 3) A Bug Tracking System (e.g. Bugzilla) Yesterday, a senior guy told me that we need at least one thing more. That is KPI(Key Performance Index). Without KPI, it is impossible to measure whether the project is progressing well or not. KPI is kind of SOFT tool compared to Maven/SVN/Bugzilla. I believe since I missed SOFT tools, there must be some other kind of tools I missed. So, anybody get some ideas what other basic tools necessary for a new project?

    Read the article

  • Combination of JFreeChart with JXLayer with JHotDraw

    - by Yan Cheng CHEOK
    Recently, I had use JXLayer, to overlay two moving yellow message boxes, on the top of JFreeChart http://yccheok.blogspot.com/2010/02/investment-flow-chart.html I was wondering, had anyone experience using JXLayer + JHotdraw, to overlay all sorts of figures (Re-sizable text box, straight line, circle...), on the top of JFreeChart. I just would like to add drawing capability, without changing the JFreeChart source code. So that, JStock's user may draw trending lines, annotation text on their favorite stock charting. The code skeleton is as follow : // this.chartPanel is JFreeChartPanel final org.jdesktop.jxlayer.JXLayer<ChartPanel> layer = new org.jdesktop.jxlayer.JXLayer<ChartPanel>(this.chartPanel); this.myUI = new MyUI<ChartPanel>(this); layer.setUI(this.myUI); public class MyUI<V extends javax.swing.JComponent> extends AbstractLayerUI<V> { @Override protected void paintLayer(Graphics2D g2, JXLayer<? extends V> layer) { // Previous, I am using my own hand-coded, to draw the yellow box // // Now, How can I make use of JHotDraw at here, to draw various type of // figures? } @Override protected void processMouseEvent(MouseEvent e, JXLayer<? extends V> layer) { // How can I make use of JHotDraw at here? } @Override protected void processMouseMotionEvent(MouseEvent e, JXLayer<? extends V> layer) { // How can I make use of JHotDraw at here? } } As you see, I already got Graphics2D g2 from paintLayer method. How is it possible that I can pass the Graphics2D object to JHotDraw, and let JHotDraw handles all the drawing. My experience in using JHotDraw are with org.jhotdraw.draw.DefaultDrawingView org.jhotdraw.draw.DefaultDrawingEditor I am able to use them to draw various figures, by clicking on the toolbar and click on drawing area. How is it possible I can use DefaultDrawingView and DefaultDrawingEditor within MyUI's paintLayer? Also, shall I let MyUI handles the mouse event, or JHotDraw? Sorry, I start getting confused.

    Read the article

  • Convert CString to string (VC6)

    - by Yan Cheng CHEOK
    I want to convert CString to string. (Yup. I know what am I doing. I know the returned string will be incorrect, if CString value range is outside ANSI, but That's Is OK!) The following code will work under VC2008. std::string Utils::CString2String(const CString& cString) { // Convert a TCHAR string to a LPCSTR CT2CA pszConvertedAnsiString (cString); // construct a std::string using the LPCSTR input std::string strStd (pszConvertedAnsiString); return strStd; } But VC6 doesn't have CT2CA macro. How I can make the code to work as well in both VC6 and VC2008?

    Read the article

  • Is it possible to prevent out-of-order execution by using single volatile

    - by Yan Cheng CHEOK
    By referring article, it is using a pair of volatile to prevent out-of-order execution. I was wondering, is it possible to prevent it using single volatile? void fun_by_thread_1() { this.isNuclearFactory = true; this.factory = new NuclearFactory(); } void fun_by_thread_2() { Factory _factory = this.factory; if (this.isNuclearFactory) { // Do not operate nuclear factory!!! return; } // If out-of-order execution happens, _factory might // be NuclearFactory instance. _factory.operate(); } Factory factory = new FoodFactory(); volatile boolean isNuclearFactory = false; The reason I ask, is because I have a single guard flag (similar to isNuclearFactory flag), to guard against multiple variables (similar to many Factory). I do not wish to mark all the Factory as volatile. Or, shall I fall into the following solution? void fun_by_thread_1() { try { writer.lock(); this.isNuclearFactory = true; this.factory = new NuclearFactory(); } finally { writer.unlock(); } } void fun_by_thread_2() { try { reader.lock(); Factory _factory = this.factory; if (this.isNuclearFactory) { // Do not operate nuclear factory!!! return; } } finally { reader.unlock(); } _factory.operate(); } Factory factory = new FoodFactory(); boolean isNuclearFactory = false; P/S: I know instanceof. Factory is just an example to demonstrate of out-of-order problem.

    Read the article

  • Sort CMap Key by String Length

    - by Yan Cheng CHEOK
    Previously, I am using STL map to perform the mentioned task. struct ltstr { bool operator()(std::string s1, std::string s2) const { const int l1 = s1.length(); const int l2 = s2.length(); if (l1 == l2) { // In alphabetical order. return s1.compare(s2) < 0; } // From longest length to shortest length. return l1 > l2; } }; std::map<std::string, int, ltstr> m; How can I perform the same task using CMap? // How to make key sorted by string length? CMap<CString, LPCTSTR, int, int> m;

    Read the article

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