Jump to content

iarp

Members
  • Posts

    326
  • Joined

  • Last visited

Everything posted by iarp

  1. When you click on a button in a form, the ID of the button that is pressed is passed. So you could just check for isset($_POST['submit']) or isset($_POST['goback'])
  2. Where does $uploadfile come from? I don't see if being initialized anywhere. Unlink also deletes the file from the server, and with your current logic it basically says "if move this file was successful, delete it"
  3. Classes don't really work that way in terms of the direct return statement. Your class should look more like this: class tempclass { public $val1; function __construct($my_var) { $this->val1 = $my_var+5; } } but really it looks like you want a function more than a class function my_func($my_var) { return $my_var+5; }
  4. In your index.php i see you keep checking for $database but never once $dbConn. Where is $dbConn set? it kind of sounds like you should be passing $database. I see it now, you need to pass $database->dbConn to the function, not $dbConn. I don't see you calling open_connection anywhere within the class either, looking at it i would figure you should add it to the end of the __construct
  5. Line 160 returns the json of errorStatus = 0, you can just add to that array and do something like below: if(rename($this->getTempDirectory() . $this->getTempName(), $this->getMainDirectory() . $finalName)) { return json_encode(array('errorStatus' => 0, 'final_filename' => $this->getMainDirectory() . $finalName)); }
  6. iarp

    URL Problem

    You're missing a bit of code here that describes what handles the ?lang=es portion, but if I were to guess, the translate() function does that? If so, I think you would be better off storing the language selection within a session variable, and using that within the translate, rather than the URL. $allowable_langs = array('en', 'es'); if (isset($_GET['lang']) && in_array($_GET['lang'], $allowable_langs)) { $_SESSION['lang'] = $_GET['lang']; } Within the translate function, just access the wanted variable by using $_SESSION['lang'];
  7. You need to turn on display_errors to see what's going on. It'll be found in the php.ini file of your servers configuration.
  8. URL Rewriting isn't strictly achieved through PHP alone, it's the web server that accepts and processes the URI request that needs to know what to do with the URL it has been given by the user. If you want to shorten /thevery/long/url.php to /my-custom-url you need to tell the web server how to process that. If you wanted a basic example, here is something similar that WordPress uses for Apache servers RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] It sends all requests to /index.php where you can then process the URL yourself, through PHP, by accessing the URI through $_SERVER['REQUEST_URI']
  9. Have you tried adding FT_INTERNAL to the imap_fetchbody $options. string imap_fetchbody ( resource $imap_stream , int $msg_number , string $section [, int $options = 0 ] ) FT_INTERNAL - The return string is in internal format, will not canonicalize to CRLF. Not 100% sure that'll do what you want, as I've never personally worked with this function before, but reading that it looks like by default it changes it to CRLF.
  10. <form id="myform" method="GET" action="<?php echo $_SERVER['$PHP_SELF'];?>"> You don't need to $ on $PHP_SELF, just PHP_SELF. But then again, if you just want the submission to go to the same page, you don't even need an action="" element.
  11. Hi all, I'm trying to work with SugarCRM's REST service, whenever you add a new email it passes the email off to a class called HTMLPurifier. I'm having issues though, passing emails to the service causes a huge delay and the web server time's out on me event if i set the timeout to 15minutes. I installed xdebug to maybe see a reason, or if there were any error messages, using kcachegrind i can look at the output file and see, with a timeout of 2 minutes, what i think i read here is that array_splice is using 97% of that time and being called 6,461 times. Even worse would be array_shift being called 12,223 times. There has to be some reason why this is taking so long to process emails through this class. I'm just stuck here because i don't know where to go next. I don't know Sugar's source well enough to pick it apart and figure out why it's bugging out like this. What's next for me to look at?
  12. I can't explain it, but changing the session name in the _config array fixed the issue. I'm guessing somewhere in my nginx or php5-fpm pool configs it also writes a session cookie and this class was simply overwriting it by accident.
  13. I'm working with this script: https://github.com/m...r/Resession.php i haven't modified it or anything yet. I'm trying to use it to get a bit better session security, today i was messing around with cookies and just copied the id from one browser to another and was magically logged in as the other browser... too insecure. and i have a test page: <?php require_once('../libs/class.Resession.php'); function debug($var) { echo '<pre>' . print_r($var, true) . '</pre>'; } $session = new Resession(array( 'security' => Resession::SECURITY_HIGH, 'cookies' => true, 'name' => 'mysite321' )); #$session->set('hi', 'testing'); debug($session->get()); debug($session); I'm having an issue where, i $session->set a value (as commented out in code above) and then print the session information. That works all fine and dandy until i refresh the page. I'm continuously getting a new session id on every refresh, and i'm losing the session information. I have commented out just about every line in that __construct function attempting to find the culprit and the ONLY thing that stops the loss of session data is commenting out ini_set('session.name', $this->_config['name']); I am not sure why it getting a new session id on every reload just because of that single line. I'm wondering if anyone could have a quick glance and let me know if i'm missing some type of detail here.
  14. return array($this->y, $this->z); list($myOwnVarForY, $myOwnVarForZ) = $X->magic();
  15. I'm in the middle of creating a system, I've just started working on the login script, each login will have custom settings that override the global setting. Is the cost of contacting the database greater than calling $_SESSION to a point that it's not worth calling the database every time? Or is it close enough it's worth it, and not having to then manage updating the database and the session variables when items are changed.
  16. I'm fairly certain it's because you need to add a beginning slash to the href. Otherwise the server will pick-up the links from the current folder it believes it's in. Apache manages the url business, PHP thinks it's in a folder and because you're missing the slash, PHP will just append the new url to the current url. <a href="'.$page.'/'.$id_team.'/'.$name.'.html">......</a> most likely should be <a href="/'.$page.'/'.$id_team.'/'.$name.'.html">......</a> Now, if you're not in the root of the domain, but a subfolder, you will need to append the subfolders name along with the starting slash.
  17. I can't help with the exact error you're getting, but this is what we use to store temporary data in cookies and such. It works, and never had errors from it thus far. function encrypt($string) { $key = 'my passphrase'; $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); return $encrypted; } function decrypt($string) { $key = 'my passphrase'; return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); }
  18. Is $tik quoted at any point before this query, otherwise it'll need single quotes. $tokens = mysql_query("SELECT user_name FROM users WHERE user_name = '$tik'");
  19. SELECT not GET. $tokens=mysql_query("GET SELECT user_name FROM users WHERE user_name=$tik");
  20. Thank-you, that works. $sth->bindParam(':' . $f, $v[0], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); No need to use tmpfile system to read it, it takes raw data.
  21. Before adding the if statement using tmpfile: declare @p1 int set @p1=NULL exec sp_prepexec @p1 output,N'@P1 nvarchar(23),@P2 nvarchar(6),@P3 nvarchar(35),@P4 nvarchar(15)',N'INSERT INTO NOTES (CREATEDDATE,USERID,NOTE,id) VALUES (@P1,@P2,@P3,@P4)',N'2012-11-24 09:28:54.000',N'CLIENT',N'test test',N'7T0adxMbhDlve4S' select @p1 Afterwards, using the tmpfile: declare @p1 int set @p1=NULL exec sp_prepare @p1 output,N'@P1 nvarchar(23),@P2 nvarchar(6),@P3 nvarchar(max),@P4 nvarchar(15)',N'INSERT INTO NOTES (CREATEDDATE,USERID,NOTE,id) VALUES (@P1,@P2,@P3,@P4)',1 select @p1 So it would seem that, it's either not preparing the statement correctly, or not executing (even though i call $sth->execute() ). I checked all running statements against the database, that is the only one that calls sp_prepare instead of sp_prepexec.
  22. CREATE TABLE [dbo].[NOTES]( [CREATEDDATE] [datetime] NOT NULL, [uSERID] [varchar]( NOT NULL, [NOTE] [image] NULL, [id] [varchar](15) NOT NULL ) $values = array( 'CREATEDDATE' => date('Y-m-d H:i:s.000'), 'USERID' => 'CLIENT', 'NOTE' => array($noteBody, 'LOB'), 'id' => $id ); Database::insert('NOTES', $values); class Database { public function conn() { try { $dsn = 'sqlsrv:server=127.0.0.1;Database = Tester'; $user = 'sa'; $pass = 'password'; $conn = new PDO($dsn, $user, $pass); $conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); return $conn; } catch(PDOException $e) { die($e->getMessage()); } } public function insert($table, $values = array()) { $dbh = self::conn(); foreach ($values as $field => $v) $ins[] = ':' . $field; $ins = implode(',', $ins); $fields = implode(',', array_keys($values)); $sql = "INSERT INTO $table ($fields) VALUES ($ins)"; $sth = $dbh->prepare($sql); foreach ($values as $f => $v) { if (is_array($v)) { switch($v[1]){ case 'LOB': $sth->bindValue(':' . $f, $v[0], PDO::PARAM_LOB); break; case 'INT': $sth->bindValue(':' . $f, $v[0], PDO::PARAM_INT); break; case 'STR': default: $sth->bindValue(':' . $f, $v[0], PDO::PARAM_STR); break; } } else { $sth->bindValue(':' . $f, $v, PDO::PARAM_STR); } } return $sth->execute(); //return $this->lastId = $dbh->lastInsertId(); } } Well, it would seem like the editor doesn't like my tabs for indentation.
  23. Added PDO::PARAM_LOB and it still passes data through as NVARCHAR. I tried PARAM_STR just for the hell of it, NVARCHAR too. Thinking these image types will require the old mssql_ functions.
  24. In an effort to be a little bit safer and better with my queries i moved from mssql_* functions to PDO using sqlsrv. One thing i did not take into account is the use of column type "image" that is used in a few areas. I have a few dozen tables that have a column named NOTE of type "image" I receive this error "Operand type clash: nvarchar is incompatible with image" and i'm wondering if anyone knows what i can do from here. I will note now, there is no changing the database in any fashion. While writing this, i decided to google one last thing and ran across this, https://bugs.php.net/bug.php?id=36961 , which scares me because it's 6 years old, open and i'm wondering if it's the same error.
×
×
  • 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.