Daily Archives

Articles indexed Monday April 9 2012

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

  • How to set up a local webDAV server for use with Goodreader on the ipad? [migrated]

    - by confused-about-webdav
    I need to know how to set up a local webDav server on my PC so that goodreader on ipad can automatically sync with it over the local wifi network? I am really a rookie when it comes to setting up a web server and have tried various guides on the internet. I tried setting up a webdav server using IIS and forwarded the required ports and enabled webdav publishing but goodreader can find it in the local wifi network automatically nor is it able to connect even after manually entering the credendtials. So i'll be really greateful if someone who has successfully setup a webdav server for use with goodreader can point me on how to do it?

    Read the article

  • How to achieve uniform speed of movement in cocos 2d?

    - by Andrey Chernukha
    I'm an absolute beginner in cocos2 , actually i started dealing with it yesterday. What i'm trying to do is moving an image along Bezier curve. This is how i do it - (void)startFly { [self runAction:[CCSequence actions: [CCBezierBy actionWithDuration:timeFlying bezier:[self getPathWithDirection:currentDirection]], [CCCallFuncN actionWithTarget:self selector:@selector(endFly)], nil]]; } My issue is that the image moves not uniformly. In the beginning it's moving slowly and then it accelerates gradually and at the end it's moving really fast. What should i do to get rid of this acceleration?

    Read the article

  • Storing game objects with generic object information

    - by Mick
    In a simple game object class, you might have something like this: public abstract class GameObject { protected String name; // other properties protected double x, y; public GameObject(String name, double x, double y) { // etc } // setters, getters } I was thinking, since a lot of game objects (ex. generic monsters) will share the same name, movement speed, attack power, etc, it would be better to have all that information shared between all monsters of the same type. So I decided to have an abstract class "ObjectData" to hold all this shared information. So whenever I create a generic monster, I would use the same pre-created "ObjectData" for it. Now the above class becomes more like this: public abstract class GameObject { protected ObjectData data; protected double x, y; public GameObject(ObjectData data, double x, double y) { // etc } // setters, getters public String getName() { return data.getName(); } } So to tailor this specifically for a Monster (could be done in a very similar way for Npcs, etc), I would add 2 classes. Monster which extends GameObject, and MonsterData which extends ObjectData. Now I'll have something like this: public class Monster extends GameObject { public Monster(MonsterData data, double x, double y) { super(data, x, y); } } This is where my design question comes in. Since MonsterData would hold data specific to a generic monster (and would vary with what say NpcData holds), what would be the best way to access this extra information in a system like this? At the moment, since the data variable is of type ObjectData, I'll have to cast data to MonsterData whenever I use it inside the Monster class. One solution I thought of is this, but this might be bad practice: public class Monster extends GameObject { private MonsterData data; // <- this part here public Monster(MonsterData data, double x, double y) { super(data, x, y); this.data = data; // <- this part here } } I've read that for one I should generically avoid overwriting the underlying classes variables. What do you guys think of this solution? Is it bad practice? Do you have any better solutions? Is the design in general bad? How should I redesign this if it is? Thanks in advanced for any replies, and sorry about the long question. Hopefully it all makes sense!

    Read the article

  • Get Final output from UDK

    - by EmAdpres
    ( sorry for my bad english in advance :D ) I'm trying to get a .exe setup output, from my UDK !( with my own maps and scripts which I made within MyGame) I tried UnrealFrontEnd! But It made a setup , that after installation I can see my .udk maps, my packages and etc. But It's not a real output that I can show to my customers. I don't want, other can use my resources ! So... How can I get a binary-like output from UDK as a real Game-Output ? ( like what we see in all commercial games ) Is there any option in frontend that I missed ?

    Read the article

  • 2D Tile based Game Collision problem

    - by iNbdy
    I've been trying to program a tile based game, and I'm stuck at the collision detection. Here is my code (not the best ^^): void checkTile(Character *c, int **map) { int x1,x2,y1,y2; /* Character position in the map */ c->upY = (c->y) / TILE_SIZE; // Top left corner c->downY = (c->y + c->h) / TILE_SIZE; // Bottom left corner c->leftX = (c->x) / TILE_SIZE; // Top right corner c->rightX = (c->x + c->w) / TILE_SIZE; // Bottom right corner x1 = (c->x + 10) / TILE_SIZE; // 10px from left side point x2 = (c->x + c->w - 10) / TILE_SIZE; // 10px from right side point y1 = (c->y + 10) / TILE_SIZE; // 10px from top side point y2 = (c->y + c->h - 10) / TILE_SIZE; // 10px from bottom side point /* Top */ if (map[c->upY][x1] > 2 || map[c->upY][x2] > 2) c->topCollision = 1; else c->topCollision = 0; /* Bottom */ if ((map[c->downY][x1] > 2 || map[c->downY][x2] > 2)) c->downCollision = 1; else c->downCollision = 0; /* Left */ if (map[y1][c->leftX] > 2 || map[y2][c->leftX] > 2) c->leftCollision = 1; else c->leftCollision = 0; /* Right */ if (map[y1][c->rightX] > 2 || map[y2][c->rightX] > 2) c->rightCollision = 1; else c->rightCollision = 0; } That calculates 8 collision points My moving function is like that: void movePlayer(Character *c, int **map) { if ((c->dirX == LEFT && !c->leftCollision) || (c->dirX == RIGHT && !c->rightCollision)) c->x += c->vx; if ((c->dirY == UP && !c->topCollision) || (c->dirY == DOWN && !c->downCollision)) c->y += c->vy; checkPosition(c, map); } and the checkPosition: void checkPosition(Character *c, int **map) { checkTile(c, map); if (c->downCollision) { if (c->state != JUMPING) { c->vy = 0; c->y = (c->downY * TILE_SIZE - c->h); } } if (c->leftCollision) { c->vx = 0; c->x = (c->leftX) * TILE_SIZE + TILE_SIZE; } if (c->rightCollision) { c->vx = 0; c->x = c->rightX * TILE_SIZE - c->w; } } This works, but sometimes, when the player is landing on ground, right and left collision points become equal to 1. So it's as if there were collision coming from left or right. Does anyone know why this is doing this?

    Read the article

  • Android/Java AI agent framework/middleware

    - by corneliu
    I am looking for an AI agent framework to use as a starting point in an Android game I have to create for a university research project. It has been suggested to me to use JADE, but, as far as I can tell, it's not a suitable framework for games (at least for my game idea) because it runs in a split-execution mode, and it needs an always-active network connection to a main host. What I want is just a little something to give me a headstart. I am willing to adjust the game's features to the framework because it's more of a mockup game, and the purpose is to compare the performance of a couple of agents in the game world. The game will be very simplistic, with a minimal UI that displays various stats about the characters in the game (so no graphics, no pathfinding). Thank you.

    Read the article

  • How to handle multiple effect files in XNA

    - by Adam 'Pi' Burch
    So I'm using ModelMesh and it's built in Effects parameter to draw a mesh with some shaders I'm playing with. I have a simple GUI that lets me change these parameters to my heart's desire. My question is, how do I handle shaders that have unique parameters? For example, I want a 'shiny' parameter that affects shaders with Phong-type specular components, but for an environment mapping shader such a parameter doesn't make a lot of sense. How I have it right now is that every time I call the ModelMesh's Draw() function, I set all the Effect parameters as so foreach (ModelMesh m in model.Meshes) { if (isDrawBunny == true)//Slightly change the way the world matrix is calculated if using the bunny object, since it is not quite centered in object space { world = boneTransforms[m.ParentBone.Index] * Matrix.CreateScale(scale) * rotation * Matrix.CreateTranslation(position + bunnyPositionTransform); } else //If not rendering the bunny, draw normally { world = boneTransforms[m.ParentBone.Index] * Matrix.CreateScale(scale) * rotation * Matrix.CreateTranslation(position); } foreach (Effect e in m.Effects) { Matrix ViewProjection = camera.ViewMatrix * camera.ProjectionMatrix; e.Parameters["ViewProjection"].SetValue(ViewProjection); e.Parameters["World"].SetValue(world); e.Parameters["diffuseLightPosition"].SetValue(lightPositionW); e.Parameters["CameraPosition"].SetValue(camera.Position); e.Parameters["LightColor"].SetValue(lightColor); e.Parameters["MaterialColor"].SetValue(materialColor); e.Parameters["shininess"].SetValue(shininess); //e.Parameters //e.Parameters["normal"] } m.Draw(); Note the prescience of the example! The solutions I've thought of involve preloading all the shaders, and updating the unique parameters as needed. So my question is, is there a best practice I'm missing here? Is there a way to pull the parameters a given Effect needs from that Effect? Thank you all for your time!

    Read the article

  • What's the best way to create animations when doing Android development?

    - by Adam Smith
    I'm trying to create my first Android game and I'm currently trying to figure out (with someone that will do the drawings and another programmer) what the best way to create animation is. (Animations such as a character moving, etc.) At first, the designer said that she could draw objects/characters and animate them with flash so she didn't have to draw every single frame of an action. The other programmer and I don't know Flash too much so I suggested extracting all the images from the Flash animation and making them appear one after the other when the animation is to start. He said that would end up taking too much resource on the CPU and I tend to agree, but I don't really see how we're supposed to make smooth animations without it being too hard on the hardware and, if possible, not have the designer draw every single frame on Adobe Illustrator. Can an experienced Android game developper help me balance this out so we can move on to other parts of the game as I have no idea what the best way to create animations is.

    Read the article

  • Converting a DrawModel() using BasicEffect to one using Effect

    - by Fibericon
    Take this DrawModel() provided by MSDN: private void DrawModel(Model m) { Matrix[] transforms = new Matrix[m.Bones.Count]; float aspectRatio = graphics.GraphicsDevice.Viewport.Width / graphics.GraphicsDevice.Viewport.Height; m.CopyAbsoluteBoneTransformsTo(transforms); Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); Matrix view = Matrix.CreateLookAt(new Vector3(0.0f, 50.0f, Zoom), Vector3.Zero, Vector3.Up); foreach (ModelMesh mesh in m.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.View = view; effect.Projection = projection; effect.World = gameWorldRotation * transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(Position); } mesh.Draw(); } } How would I apply a custom effect to a model with that? Effect doesn't have View, Projection, or World members. This is what they recommend replacing the foreach loop with: foreach (ModelMesh mesh in terrain.Meshes) { foreach (Effect effect in mesh.Effects) { mesh.Draw(); } } Of course, that doesn't really work. What else needs to be done?

    Read the article

  • PhoneGap + JqueryMobile on Xcode

    - by aeternus828
    Attempting a beginner's tutorial. I have the following in my head: <script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script> <linkrel="stylesheet"href="http://code.jquery.com/mobile/1.0.1/jquery.mobile1.0.1.min.css" /> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> My result is just text, no Jquery mobile styling.

    Read the article

  • Creating an array & outputting its code definition for preloading

    - by user422318
    I want to create a 2d array that represents my 2d canvas. For each pixel, I will look up the value and then save an integer {0, 1, 2, 3, 4} as each element of the array. Unfortunately, this takes way too friggin' long to run each time I load the game. How can I write a script that creates this array for me and outputs the array code so I can just paste it in a js file and have it preloaded? (I'm prototyping a game, so I just need to run this for my test map or two.)

    Read the article

  • #ifndef syntax for include guards in C++

    - by PhADDinTraining
    I'm currently studying for a CS course's final exam and I've run into a minor (maybe major?) issue regarding the syntax of C++ #ifndef. I've looked at the syntax for #infndef when using it as an #include guard, and most on the web seem to say: #ifndef HEADER_H #include "header.h" ... #endif But my class's tutorial slides show examples as: #ifndef __HEADER_H__ #include "header.h" ... #endif I was wondering what (if any) the difference was between the two. The exam will most likely ask me to write an #include guard, and I know conventional wisdom is to just go with what the prof / tutor says, but if there's a difference during compilation I'd like to know. Thanks all!

    Read the article

  • org.hibernate.annotations.Entity not being picked up by Hibernate 3.6

    - by user1317764
    I am using hibernate 3.6.7 I am using annotated classes. My classes were annotated with org.hibernate.annotations.Entity. Added the classes to configuration using configuration.addAnnotatedClass() method. Hibernate does not seem to pick it up. Stuff works fine if I use the standard jpa Entity annotation. What am I missing? I know that the classes have been deprecated in the Hibernate 4.x releases with the advent of newer annotations to configure stuff like dynamic-insert and dynamic-updates. I am not using any XML configuration file. I am setting up configuration with a properties file and using java apis.

    Read the article

  • Multi lined Multi styled button

    - by user1321811
    Hi i'm trying to recreate this button style more specifically the 'view basket' button. waitrose app The button needs to have multiple lines of text each with a different text size and font colour etc. Here's the code so far. I've created the button and its displays correctly but when you click on it the state pressed isn't working. Where am I going wrong. Thanks in advance. xml button file: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:state_pressed="true" android:state_focused="true" android:background="@drawable/button_bg" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Some Text" android:state_pressed="false" android:state_focused="false" android:textColor="#ffffff" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Some Text" android:state_pressed="false" android:state_focused="false" android:textColor="#ffffff" /> </LinearLayout> java file code: package com.buttons2; import com.buttons2.R; import android.app.Activity; import android.os.Bundle; import android.widget.Button; public class Buttons2Activity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.button1); setContentView(R.layout.button); } }

    Read the article

  • Change DIV background color for all inputs in form

    - by Erik
    I have a form with 20 input fields. Each input field is inside a DIV I have a script that changes the background color of the DIV via keyup function along with two other DIV tags. Rather than duplicating the script 20 times for each DIV and Input, is it possible to re-write the script to do all DIV's and their Inputs? <script> $(document).ready(function(){ $("#id").keyup(function() { if($("#id").val().length > 0) $("#in1, #nu1, #lw1, #id").css("background-color", "#2F2F2F").css("color", "#FFF"); else { if($("#id").val().length == 0) $("#in1, #nu1, #lw1, #id").css("background-color", "#E8E8E8").css("color", "#000"); } }); }); </script>

    Read the article

  • Why Bluetooth needs DBUS way of communication in android?

    - by Rajesh SO
    I am newbie to Android DBUS, recently I was informed that I need to use DBUS to implement Bluetooth in Android, from DBUS documentation I see DBUS is used for communication medium between two applications. In Android apps -apps communication is through intents, if so why do we need DBUS for Bluetooth ? Is that DBUS serves as communication medium for networking (IP) between two apps since it is built over sockets? Please correct me if my understanding is wrong, any more information on DBUS along with Bluetooth implementation in Android is appreciated. Thanks.

    Read the article

  • Implementing simple business model in Haskell

    - by elmes
    Supose we have a very simple model: Station has at least one Train Train has at least two Stations The model has to allow to check what stations any given train visits and to check what trains visit a particular station. How to model it in Haskell? I am a Haskell newbie, so please correct me: once an object is created, you cannot modify it - you can only make a new object based on that one (~immutability). Am I right? If so, I'll have to create a lot of temporary variables with semi-initialized objects (during deserialization or even in unit tests). Basically what I need is an example of modeling domain classes in Haskell - after reading "Learn you a haskell.." I still have no idea how to use this language.

    Read the article

  • Facebook PHP SDK - can't pass parameters to getLoginUrl()

    - by Elliott
    I'm using the Facebook PHP SDK for simple login with extended permissions. I'm using the example code from the SDK docs, but I found that I need to manually clear out the FB session data otherwise if($user) comes back as true even though the user is logged out. I have the app going to logout.php upon logout; this page clears out the session vars and redirects to the app home page. Once I clear out the FB session data, log in/log out works fine. However, it stops working if I pass $params to the getLoginUrl function. Once I pass any params (I've tried several), the login breaks, either by not bringing up the second extended permissions screen or by refreshing the app page w/out login success. index page and logout page code follow. index.php <?php require 'services/facebook-php-sdk/src/facebook.php'; $facebook = new Facebook(array( 'appId' => '[APP_ID]', 'secret' => '[SECRET]', )); // Get User ID $user = $facebook->getUser(); if($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); $params = array('next' => 'http://'.$_SERVER["SERVER_NAME"].'/logout.php'); $logout_url = $facebook->getLogoutUrl($params); } catch (FacebookApiException $e) { error_log($e); $user = null; } } else { $login_url = $facebook->getLoginUrl($params = array('redirect_uri' => 'http://'.$_SERVER["SERVER_NAME"].'/', 'scope' => 'read_stream')); } ?> <!DOCTYPE html> <html lang="en"> <head> </head> <body> <?php if($user) { ?> <p><a href="<?php echo($logout_url); ?>">Log out</a></p> <?php } else { ?> <p><a href="<?php echo($login_url); ?>">Log in</a></p> <?php } ?> </body> </html> logout.php <?php session_start(); $fb_app_id = '[APP_ID]'; unset($_SESSION['fb_'.$fb_app_id.'_code']); unset($_SESSION['fb_'.$fb_app_id.'_access_token']); unset($_SESSION['fb_'.$fb_app_id.'_user_id']); unset($_SESSION['fb_'.$fb_app_id.'_state']); header('Location: http://'.$_SERVER["SERVER_NAME"].'/'); ?>

    Read the article

  • Linux file names & file globbing

    - by John Lelos
    I have a list of files named: file000 file001 file002 file003 ... file1100 How can I match all files that have a number greater than 800 but less than 1000 ? I am using linux bash Thank you Edit Actually, my files are named like: ab869.enc cp936.enc g122345.enc x2022.enc abc8859-14.enc aax5601.enc cp936-1.enc so the first solution dont match the correct files :( How can I match files that have number between 800-999 ?

    Read the article

  • Inconsistent accessibility

    - by user1312412
    I am getting the following error Inconsistent accessibility: parameter type 'Db.Form1.ConnectionString' is less accessible than method 'Db.Form1.BuildConnectionString(Db.Form1.ConnectionString)' //Name spaces using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.VisualBasic; using System.Collections; using System.Diagnostics; using System.Data.OleDb; using System.IO; using System.Drawing.Printing; // namespace Db { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void SetBusy() { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); } public void SetFree() { this.Cursor = Cursors.Default; Application.DoEvents(); } //connection string into parts struct ConnectionString { public string Provider; public string DataSource; public string UserId; public string Password; public string Database; } //Declare public string BuildConnectionString(ConnectionString connStr) ------> getting error here { string[] parts = new string[5]; parts[0] = "Provider=" + connStr.Provider; parts[1] = "Data Source=" + connStr.DataSource; parts[2] = "User Id=" + connStr.UserId; parts[3] = "Password=" + connStr.Password; parts[4] = "Initial Catalog=" + connStr.Database; return string.Join(";", parts); } // settings public bool IsValidConnectionForPrinting() { SetBusy(); ConnectionString connStr = new ConnectionString(); connStr.Provider = cboProvider.Text; connStr.DataSource = cboDataSource.Text; connStr.UserId = txtUserId.Text; connStr.Password = txtPassword.Text; connStr.Database = cboDatabase.Text; //connection string to database string connectionString = BuildConnectionString(connStr); OleDbConnection conn = new OleDbConnection(connectionString); try { conn.Open(); OleDbCommand cmd = conn.CreateCommand; cmd.CommandType = CommandType.TableDirect; cmd.CommandText = "vw_pr_DL"; cmd.ExecuteScalar(); cmd.CommandText = "vw_pr_VR"; cmd.ExecuteScalar(); //cmd.CommandText = "vw_pr_VR" //cmd.ExecuteScalar() conn.Close(); } //Exception messages catch (Exception ex) { SetFree(); if (ex.Message.StartsWith("Invalid object name")) { MessageBox.Show(ex.Message.Replace("Invalid object name", "Table or view not found"), "Connection Test"); } else { MessageBox.Show(ex.GetBaseException().Message, "Connection Test"); } return false; } SetFree(); return true; } // when user click testbutton private void btnConnTest_Click(object sender, EventArgs e) { if (IsValidConnectionForPrinting()) { MessageBox.Show("Connection succeeded", "Connection Test"); } }

    Read the article

  • XPath to find ancestor node containing CSS class

    - by Juan Mendes
    I am writing some Selenium tests and I need to be able to find an ancestor of a WebElement that I have already found. This is what I'm trying but is returning no results // checkbox is also a WebElement WebElement container = checkbox.findElement(By.xpath( "current()/ancestor-or-self::div[contains(@class, 'x-grid-view')]") ); The image below shows the div that I have selected highlighted in dark blue and the one I want to find with an arrow pointing at it. UPDATE Tried prestomanifesto's suggestion and got the following error [cucumber] org.openqa.selenium.InvalidSelectorException: The given selector ./ancestor::div[contains(@class, 'x-grid-view']) is either invalid or does not result in a WebElement. The following error occurred: [cucumber] [InvalidSelectorError] Unable to locate an element with the xpath expression ./ancestor::div[contains(@class, 'x-grid-view']) because of the following error: [cucumber] [Exception... "The expression is not a legal expression." code: "51" nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)" location: "file:///C:/Users/JUAN~1.MEN/AppData/Local/Temp/anonymous849245187842385828webdriver-profile/extensions/fxdriv Update 2 Really weird, even by ID is not working [cucumber]       org.openqa.selenium.NoSuchElementException: Unable to locate element:{"method":"xpath","selector":"./ancestor::div[@id='gridview-1252']"}

    Read the article

  • PHP Multiple User Login Form - Navigation to Different Pages Based on Login Credentials

    - by Zulu Irminger
    I am trying to create a login page that will send the user to a different index.php page based on their login credentials. For example, should a user with the "IT Technician" role log in, they will be sent to "index.php", and if a user with the "Student" role log in, they will be sent to the "student/index.php" page. I can't see what's wrong with my code, but it's not working... I'm getting the "wrong login credentials" message every time I press the login button. My code for the user login page is here: <?php session_start(); if (isset($_SESSION["manager"])) { header("location: http://www.zuluirminger.com/SchoolAdmin/index.php"); exit(); } ?> <?php if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["role"])) { $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]); $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]); $role = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["role"]); include "adminscripts/connect_to_mysql.php"; $sql = mysql_query("SELECT id FROM Users WHERE username='$manager' AND password='$password' AND role='$role' LIMIT 1"); $existCount = mysql_num_rows($sql); if (($existCount == 1) && ($role == 'IT Technician')) { while ($row = mysql_fetch_array($sql)) { $id = $row["id"]; } $_SESSION["id"] = $id; $_SESSION["manager"] = $manager; $_SESSION["password"] = $password; $_SESSION["role"] = $role; header("location: http://www.zuluirminger.com/SchoolAdmin/index.php"); } else { echo 'Your login details were incorrect. Please try again <a href="http://www.zuluirminger.com/SchoolAdmin/index.php">here</a>'; exit(); } } ?> <?php if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["role"])) { $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]); $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]); $role = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["role"]); include "adminscripts/connect_to_mysql.php"; $sql = mysql_query("SELECT id FROM Users WHERE username='$manager' AND password='$password' AND role='$role' LIMIT 1"); $existCount = mysql_num_rows($sql); if (($existCount == 1) && ($role == 'Student')) { while ($row = mysql_fetch_array($sql)) { $id = $row["id"]; } $_SESSION["id"] = $id; $_SESSION["manager"] = $manager; $_SESSION["password"] = $password; $_SESSION["role"] = $role; header("location: http://www.zuluirminger.com/SchoolAdmin/student/index.php"); } else { echo 'Your login details were incorrect. Please try again <a href="http://www.zuluirminger.com/SchoolAdmin/index.php">here</a>'; exit(); } } ?> And the form that the data is pulled from is shown here: <form id="LoginForm" name="LoginForm" method="post" action="http://www.zuluirminger.com/SchoolAdmin/user_login.php"> User Name:<br /> <input type="text" name="username" id="username" size="50" /><br /> <br /> Password:<br /> <input type="password" name="password" id="password" size="50" /><br /> <br /> Log in as: <select name="role" id="role"> <option value="">...</option> <option value="Head">Head</option> <option value="Deputy Head">Deputy Head</option> <option value="IT Technician">IT Technician</option> <option value="Pastoral Care">Pastoral Care</option> <option value="Bursar">Bursar</option> <option value="Secretary">Secretary</option> <option value="Housemaster">Housemaster</option> <option value="Teacher">Teacher</option> <option value="Tutor">Tutor</option> <option value="Sanatorium Staff">Sanatorium Staff</option> <option value="Kitchen Staff">Kitchen Staff</option> <option value="Parent">Parent</option> <option value="Student">Student</option> </select><br /> <br /> <input type="submit" name = "button" id="button" value="Log In" onclick="javascript:return validateLoginForm();" /> </h3> </form> Once logged in (and should the correct page be loaded, the validation code I have at the top of the script looks like this: <?php session_start(); if (!isset($_SESSION["manager"])) { header("location: http://www.zuluirminger.com/SchoolAdmin/user_login.php"); exit(); } $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); $role = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["role"]); include "adminscripts/connect_to_mysql.php"; $sql = mysql_query("SELECT id FROM Users WHERE username='$manager' AND password='$password' AND role='$role' LIMIT 1"); $existCount = mysql_num_rows($sql); if ($existCount == 0) { header("location: http://www.zuluirminger.com/SchoolAdmin/index.php"); exit(); } ?> Just so you're aware, the database table has the following fields: id, username, password and role. Any help would be greatly appreciated! Many thanks, Zulu

    Read the article

  • scaling svg paths in Raphael 2.1

    - by user1229001
    I'm using SVG paths from a wikimedia commons map of the US. I've singled out Pennsylvania with its counties. I'm feeding the paths out of a database and using Raphael 2.1 to put them on the page. Because in the original map, Pennsylvania was so small and set at an angle, I'd like to scale up the paths and rotate Pa. so that it isn't on an angle. When I try to use Raphael's transform method, all the counties look strange and overlapped. I gave up on setting the viewBox when I heard that it doesn't work in all browsers. Anyone have any ideas? Here is my code: $(document).ready(function() { var $paths = []; //array of paths var $thisPath; //variable to hold whichever path we're drawing $.post('getmapdata.php', function(data){ var objData = jQuery.parseJSON(data); for (var i=0; i<objData.length; i++) { $paths.push(objData[i].path); //$counties.push(objData[i].name); }//end for drawMap($paths); }) function drawMap(data) { // var map = new Raphael(document.getElementById('map_div_id'),0, 0); var map = new Raphael(0, 0, 520, 320); //map.setViewBox(0,0,500,309, true); for (var i = 0; i < data.length; i++) { var thisPath = map.path(data[i]); thisPath.transform(s2); thisPath.attr({stroke:"#FFFFFF", fill:"#CBCBCB","stroke-width":"0.5"}); } //end cycling through i }//end drawMap });//end program

    Read the article

  • Reverting back to previous ADT plugin

    - by sdfwer
    Now I was wondering if anyone has been able to accomplish reverting to a previous ADT plugin. The reason for this is because I am using an open source jar and I am getting the following errors on my LogCat such as: unable to resolve virtual method unable to find class referenced in signature unable to resolve new-instance The effect of this causes an error on running my android application on the debugger. I was using android ADT 15 before now I am updated to 17. Please help on finding a solution to resolve the issue. Edit* Forgot to add in The error "java.lang.NoClassDefFoundError". In simple terms it can't find classes or methods the attached jar even though it allows it.

    Read the article

  • Why put a DAO layer over a persistence layer (like JDO or Hibernate)

    - by Todd Owen
    Data Access Objects (DAOs) are a common design pattern, and recommended by Sun. But the earliest examples of Java DAOs interacted directly with relational databases -- they were, in essence, doing object-relational mapping (ORM). Nowadays, I see DAOs on top of mature ORM frameworks like JDO and Hibernate, and I wonder if that is really a good idea. I am developing a web service using JDO as the persistence layer, and am considering whether or not to introduce DAOs. I foresee a problem when dealing with a particular class which contains a map of other objects: public class Book { // Book description in various languages, indexed by ISO language codes private Map<String,BookDescription> descriptions; } JDO is clever enough to map this to a foreign key constraint between the "BOOKS" and "BOOKDESCRIPTIONS" tables. It transparently loads the BookDescription objects (using lazy loading, I believe), and persists them when the Book object is persisted. If I was to introduce a "data access layer" and write a class like BookDao, and encapsulate all the JDO code within this, then wouldn't this JDO's transparent loading of the child objects be circumventing the data access layer? For consistency, shouldn't all the BookDescription objects be loaded and persisted via some BookDescriptionDao object (or BookDao.loadDescription method)? Yet refactoring in that way would make manipulating the model needlessly complicated. So my question is, what's wrong with calling JDO (or Hibernate, or whatever ORM you fancy) directly in the business layer? Its syntax is already quite concise, and it is datastore-agnostic. What is the advantage, if any, of encapsulating it in Data Access Objects?

    Read the article

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