Jump to content

googlexx

Members
  • Posts

    38
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

googlexx's Achievements

Member

Member (2/5)

0

Reputation

  1. This is my first oop php library and wanted to get advice on how I can improve what I wrote. This is what I needed to do: I'm also not sure on what it meant by "proportionally resize the shape up or down, given a floating-point scale factor" I think what I did might be right but I could be wrong. Also am I supposed to have a new class for each shape or is there a better solution? Any help is much appreciated. <?PHP echo "Circle (r=5) <br/>"; $circle = new circle(5); $circle->getArea(); $circle->getPerimiter(); $circle->scale(up, .5); echo "Scaled up .5<br/>"; $circle->getArea(); $circle->getPerimiter(); echo "<br/>Right Triangle (a=4, b=5) <br/>"; $rt = new RightTriangle(4, 5); $rt->getArea(); $rt->getPerimiter(); $rt->scale(down, .5); echo "Scaled down .5<br/>"; $rt->getArea(); $rt->getPerimiter(); echo "<br/>Equilateral Triangle <br/>"; $et = new EquilateralTriangle(6); $et->getArea(); $et->getPerimiter(); $et->scale(up, .; echo "Scaled Up .8<br/>"; $et->getArea(); $et->getPerimiter(); echo "<br/>Rectangle<br/>"; $r = new Rectangle(8, 7); $r->getArea(); $r->getPerimiter(); $r->scale(down, .; echo "Scaled Down .8<br/>"; $r->getArea(); $r->getPerimiter(); echo "<br/>Square<br/>"; $s = new Square(25); $s->getArea(); $s->getPerimiter(); $s->scale(up, 2.5); echo "Scaled Up 2.5<br/>"; $s->getArea(); $s->getPerimiter(); echo "<br/>Parallelogram<br/>"; $p = new Parallelogram(5.7, 6.; $p->getArea(); $p->getPerimiter(); $p->scale(up, 1); echo "Scaled Up 1<br/>"; $p->getArea(); $p->getPerimiter(); class Circle { public function __construct( $radius ) { $this->radius = $radius; } public function getArea() { echo number_format(pow($this->radius, 2) * M_PI, 2)."<br/>"; } public function getPerimiter() { echo number_format(2 * M_PI * $this->radius, 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->radius = $this->radius + ($this->radius * $scale); } else { $this->radius = $this->radius - ($this->radius * $scale); } } } class RightTriangle { public function __construct( $a, $b ) { $this->a = $a; $this->b = $b; } public function getArea() { echo number_format(($this->a*$this->b/2), 2)."<br/>"; } public function getPerimiter() { echo number_format($this->a + $this->b + sqrt(pow($this->a, 2) + pow($this->b, 2)), 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); $this->b = $this->b + ($this->b * $scale); } else { $this->a = $this->a - ($this->a * $scale); $this->b = $this->b + ($this->b * $scale); } } } class EquilateralTriangle { public function __construct( $a ) { $this->a = $a; } public function getArea() { echo number_format((sqrt(3)/4)*pow($this->a,2),2)."<br/>"; } public function getPerimiter() { echo number_format(3 * $this->a, 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); } else { $this->a = $this->a - ($this->a * $scale); } } } class Rectangle { public function __construct( $w, $l ) { $this->w = $w; $this->l = $l; } public function getArea() { echo number_format($this->w * $this->l,2)."<br/>"; } public function getPerimiter() { echo number_format(2 * ($this->w + $this->l), 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->w = $this->w + ($this->w * $scale); $this->l = $this->l + ($this->l * $scale); } else { $this->w = $this->w - ($this->w * $scale); $this->l = $this->l - ($this->l * $scale); } } } class Square { public function __construct( $a ) { $this->a = $a; } public function getArea() { echo number_format(pow($this->a,2),2)."<br/>"; } public function getPerimiter() { echo number_format(4 * $this->a, 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); } else { $this->a = $this->a - ($this->a * $scale); } } } class Parallelogram { public function __construct( $a, $b ) { $this->a = $a; $this->b = $b; $this->h = $a/$b; } public function getArea() { echo number_format($this->b * $this->h,2)."<br/>"; } public function getPerimiter() { echo number_format(2 * ($this->a + $this->b), 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); $this->b = $this->b + ($this->b * $scale); } else { $this->a = $this->a - ($this->a * $scale); $this->b = $this->b - ($this->b * $scale); } } } ?>
  2. i'm trying to call a php file using ajax and it seems to be returning false, but i have no idea why. any ideas? <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <form method="get" action="test.php"> <input id="myvar" type="hidden" name="albumid" /> <button type="submit" id="btnsubmit">Submit</button> </form> <script type="text/javascript"> $('form').submit(function() { $.ajax({ url: "newAlbum.php", data: {albumid: $('#myvar').val()}, success: function(data){ var album = data; $('#myvar').val(album); return true; } }); return false; }); </script> newAlbum.php <?php echo '11'; ?> test.php <?php echo $_GET["albumid"]; ?>
  3. Hey guys, I've setup a php fb login on my site and its working perfectly. However, I'm trying to get it to remember the person so everytime they close their browser they dont have to click login again. I've tried storing the cookie but i'm not sure its working or if its even possible with facebook. Im using this: https://developers.facebook.com/docs/reference/php/ <?php /** * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ require_once "base_facebook.php"; /** * Extends the BaseFacebook class with the intent of using * PHP sessions to store user ids and access tokens. */ class Facebook extends BaseFacebook { const FBSS_COOKIE_NAME = 'fbss'; // We can set this to a high number because the main session // expiration will trump this. const FBSS_COOKIE_EXPIRE = 31556926; // 1 year // Stores the shared session ID if one is set. protected $sharedSessionID; /** * Identical to the parent constructor, except that * we start a PHP session to store the user ID and * access token if during the course of execution * we discover them. * * @param Array $config the application configuration. Additionally * accepts "sharedSession" as a boolean to turn on a secondary * cookie for environments with a shared session (that is, your app * shares the domain with other apps). * @see BaseFacebook::__construct in facebook.php */ public function __construct($config) { if (!session_id()) { session_start(); } parent::__construct($config); if (!empty($config['sharedSession'])) { $this->initSharedSession(); } } protected static $kSupportedKeys = array('state', 'code', 'access_token', 'user_id'); protected function initSharedSession() { $cookie_name = $this->getSharedSessionCookieName(); if (isset($_COOKIE[$cookie_name])) { $data = $this->parseSignedRequest($_COOKIE[$cookie_name]); if ($data && !empty($data['domain']) && self::isAllowedDomain($this->getHttpHost(), $data['domain'])) { // good case $this->sharedSessionID = $data['id']; return; } // ignoring potentially unreachable data } // evil/corrupt/missing case $base_domain = $this->getBaseDomain(); $this->sharedSessionID = md5(uniqid(mt_rand(), true)); $cookie_value = $this->makeSignedRequest( array( 'domain' => $base_domain, 'id' => $this->sharedSessionID, ) ); $_COOKIE[$cookie_name] = $cookie_value; if (!headers_sent()) { $expire = time() + self::FBSS_COOKIE_EXPIRE; setcookie($cookie_name, $cookie_value, $expire, '/', '.'.$base_domain); } else { // @codeCoverageIgnoreStart self::errorLog( 'Shared session ID cookie could not be set! You must ensure you '. 'create the Facebook instance before headers have been sent. This '. 'will cause authentication issues after the first request.' ); // @codeCoverageIgnoreEnd } } /** * Provides the implementations of the inherited abstract * methods. The implementation uses PHP sessions to maintain * a store for authorization codes, user ids, CSRF states, and * access tokens. */ protected function setPersistentData($key, $value) { if (!in_array($key, self::$kSupportedKeys)) { self::errorLog('Unsupported key passed to setPersistentData.'); return; } $session_var_name = $this->constructSessionVariableName($key); $_SESSION[$session_var_name] = $value; } protected function getPersistentData($key, $default = false) { if (!in_array($key, self::$kSupportedKeys)) { self::errorLog('Unsupported key passed to getPersistentData.'); return $default; } $session_var_name = $this->constructSessionVariableName($key); return isset($_SESSION[$session_var_name]) ? $_SESSION[$session_var_name] : $default; } protected function clearPersistentData($key) { if (!in_array($key, self::$kSupportedKeys)) { self::errorLog('Unsupported key passed to clearPersistentData.'); return; } $session_var_name = $this->constructSessionVariableName($key); unset($_SESSION[$session_var_name]); } protected function clearAllPersistentData() { foreach (self::$kSupportedKeys as $key) { $this->clearPersistentData($key); } if ($this->sharedSessionID) { $this->deleteSharedSessionCookie(); } } protected function deleteSharedSessionCookie() { $cookie_name = $this->getSharedSessionCookieName(); unset($_COOKIE[$cookie_name]); $base_domain = $this->getBaseDomain(); setcookie($cookie_name, '', 1, '/', '.'.$base_domain); } protected function getSharedSessionCookieName() { return self::FBSS_COOKIE_NAME . '_' . $this->getAppId(); } protected function constructSessionVariableName($key) { $parts = array('fb', $this->getAppId(), $key); if ($this->sharedSessionID) { array_unshift($parts, $this->sharedSessionID); } return implode('_', $parts); } }
  4. Hey everyone, I'm having some trouble sizing a flash object inside a div. I'm trying to get it when you resize the window the flash objects resizes as well but it keeps its dimensions. This is what I have: When I change #flashcontent to height and width of 100% it does what I want it to do but I dont want it the entire size of the page I'm trying to get it the full size of a div. Any help is appreciated. Thanks <style type="text/css"> html { height: 100%; } #flashcontent { height: 480px; width: 720px; } #content { position: absolute; height: 100%; width: 100%; } /* end hide */ body { height: 100%; margin: 0; padding: 0; background-color: #eee; } </style> </head> <body> <div id="content"> <div id="flashcontent"> <object style='height:100%;' type="application/x-shockwave-flash" height="100%" width="100%" id="live_embed_player_flash" data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=dotahut" bgcolor="#000000"><param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="allowNetworking" value="all" /><param name="movie" value="http://www.twitch.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=www.twitch.tv&channel=dotahut&auto_play=true&start_volume=25" /></object> </div> </div> </body>
  5. nevermind i figured it out. for syntax issues is there a better way to grab more nodes than this? $xml = simplexml_load_file('http://xml.heroesofnewerth.com/xml_requester.php?f=match_stats&opt=mid&mid[]=30428528'); $i = 0; $result = $xml->xpath("//stat[@name='nickname']"); // Selects all the stat elements that have an attribute named 'name' with a value of 'nickname' foreach($result as $node){ $name_array[$i] = "$node"; $i++; } $i=0; $result = $xml->xpath("//stat[@name='level']"); // Selects all the stat elements that have an attribute named 'name' with a value of 'nickname' foreach($result as $node){ $level_array[$i] = "$node"; $i++; }
  6. How would I go about this?
  7. I've been reading parsing xml with php forums all day and still can't seem to figure out how to start with this one. there is a node here: http://xml.heroesofnewerth.com/xml_requester.php?f=match_stats&opt=mid&mid[]=30428528 called match_stats. All i need help with is how to get those 10 elements inside match_stats and how to grab the stat name= nickname from each element. I'm just looking for somewhere to start and I'm sure I can figure out the rest. Thanks
  8. using your code. you actually didn't put the image over the flash video. I make the video size bigger and this is what i get: http://fresnomystery.com/test/test.html
  9. yeah, i've tried both transparent and opaque. I manage to fix the video showing. And for even better testing I added in the exact same code you did for your video. http://fresnomystery.com It shows up but as you can see it still overlaps the background image. I've searched the css file for any other z-index values and it only has the two we have added.
  10. alright. I have isolated it on a single page: http://fresnomystery.com/test.html and it still isn't working. this is the main page I have it on: http://fresnomystery.com I'm stuck. I copied everything you had and it's not working on my site :/
  11. thanks for the help. I've tried everything you said and it's still not showing up. This is my html page: <!--Video Player Container. This is where the player embed code goes--> <div id="mid-content"> <div id="flash"> <div name="mediaspace" id="mediaspace"></div> </div> </div> <script type="text/javascript" src="[var.base_url]/jw_player/swfobject.js"> var so = new SWFObject("[var.base_url]/jw_player/flvplayer.swf","video","694","343","7"); so.addParam("wmode","transparent"); so.addParam("allowScriptAccess", "always"); so.addParam("allowfullscreen","true"); so.addVariable("bufferlength", "[var.video_buffer_time]"); so.addVariable("fullscreen","true"); so.addVariable("width","690"); so.addVariable("height","346"); so.addVariable("stretching", "exactfit"); so.addVariable("autostart", "false"); so.addVariable("file","[var.video_play]"); so.addVariable("skin","[var.base_url]/jw_player/modieus.zip"); so.addVariable("provider", "http"); so.addVariable("streamer","[var.base_url]/jw_player/xmoov.php"); so.addVariable("logo", "[var.base_url]/images/playerlogos/logo-player.png"); so.addVariable("image","[var.base_url]/uploads/player_thumbs/[var.video_thumb]"); so.addVariable("controlbar", "over"); so.addVariable("volume", "100"); so.write("mediaspace"); </script> <!--End Video Player Container--> and the css: #mid-content{ width:762px;/*width of the background image*/ height: 394px; margin:0 auto; text-align: center; background: url('../images/player_bg.png') no-repeat; position:relative; /*parent for object*/ z-index: 1; } #flash{/*container div for flash*/ position:absolute; z-index: -2; top:34px; left:45px;/* tricky positioning */ } now the flash video is just gone. and all i see is the background image.
  12. yeah, I did search and the problem is that since I have images as a border I I think the flash has to be inside the divs? I've tried making the border without having it inside and it doesnt show up :/
  13. yeah i've tried both and still no result. I'm not sure what else to try
  14. hey guys, I have a border I made using css and div's and want to add a flash video behind this border so the border can overlap the video. I've been trying for hours and can't seem to figure it out. Here is my page: Code: <div style="float: left; width:730px;"><div class="clsCommonSide"> <div class="f_tb"> <div class="f_bb"> <div class="f_lb"> <div class="f_rb"> <div class="f_tlc"> <div class="f_trc"> <div class="f_blc"> <div class="f_brc"> <div class="cls100_p clearfix"> <!--<h2>[var.lang_latest_videos]</h2>--> *****FLASH VIDEO HERE****** </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> and my css for the borders: Code: .f_tb{ background:url(../images/round/f_tb_full.png) no-repeat 2px 3px; } .f_bb{ background:url(../images/round/f_bb_full.png) no-repeat center 354px; } .f_lb{ background:url(../images/round/f_lb_full.png) 6px 0px no-repeat; } .f_rb{ background:url(../images/round/f_rb_full.png) 706px center no-repeat; } .f_tlc{ background:url(../images/round/f_tlc.png) left top no-repeat; } .f_trc{ background:url(../images/round/f_trc.png) 704px top no-repeat; } .f_blc{ background:url(../images/round/f_blc.png) 4px bottom no-repeat; } .f_brc{ background:url(../images/round/f_brc.png) 655px bottom no-repeat; } * html .cls100_p{ width:100%; } I have added the transparency to the flash video and have tried everything I found in google and nothing works!
  15. let me try to explain it better: 1. A user joins a page. (User A) 2. He stays on the page for 10 minutes. 3. Another user joins that same page. (User B) 4. It tells (UserB) someone else is already on the page and starts a 60 second timer for them. 5. It goes back to the page (User A) is on and shows him that someone else is trying to go on the page. It then shows him the 60 seconds timer. 6. When the 60 second timer finishes it redirects (User A) off the page and redirects (User B) onto the page. I hope that makes sense. So far i have everything done except the part with the timer and redirecting.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.