Jump to content

simonsays

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

simonsays's Achievements

Member

Member (2/5)

0

Reputation

  1. I am building a small admin panel with ability to upload videos and convert them to FLV. As far as I understand FFMPEG is enough for this. However, there are additional recommended tools like FLV2TOOL or Lame MP3 Encoder. Could anyone provide me with good explanation, what is crucial for good system with converting functionality? Thanks in advance!
  2. thanks, it's better now? but why doesn't the picture stretch to the limits? it's filled with black: http://www.kashmirecarpet.com/pics/tn9FD5~1.JPG
  3. hi there! My problem is the following. I am trying to write a function that will cut out a fixed-size piece from the CENTER of an uploaded picture. However, my function seems to always cut out a piece from the bottom right corner of the image (filling the difference with black), although the image itself is rather large and the coordinates are given. Thanks in advance! Here's the code! function CreateThumb($filename) { $source = imagecreatefromjpeg($filename); $width = imagesx($source); $height = imagesy($source); $output_width = 215; $output_height = 212; $center_hor = $width/2; $center_vert = $height/2; $src_x = $center_hor - $output_width/2; $src_y = $center_vert + $output_height/2; $output = imagecreatetruecolor($output_width, $output_height); imagecopyresampled($output, $source, 0, 0, $src_x, $src_y, $output_width, $output_height, $width, $height); $new = basename($filename); imagejpeg($output, dirname($filename).'/tn'.$new, 100); imagedestroy($source); imagedestroy($output); } }
  4. Hello! I am trying to make a script that is capable of getting and displaying (using Smarty) any database table. Something like that: function getTableAll ($table) { $data = array(); $sql = pg_query("SELECT * FROM $table"); while ($row = pg_fetch_array($sql)){ array_push($data, $row); } return $data; } function getFields ($table) { $fields = array(); $sql = pg_query("SELECT * FROM $table"); $i = pg_num_fields ($sql); $j = 0; while ($j < $i) { $fields[] = pg_field_name ($sql, $j); $j++; } return $fields; } $smarty->assign('data', $data); $smarty->assign('fields', $fields); The problems come when I try to display table using Smarty, because the template engine does not have any FOR loop or something like that. {section name=a loop=$fields} <td bgcolor="#1A2F4A"><p class='main'>{$fields[a]}</p></td> {/section} {section name=b loop=$data} </tr> ????? <tr> {/section} Can anyone help?
  5. Hello! I have a smarty template, that works fine. However, when I copy-paste template code into Notepad and save it as Unicode, the PHP script gives my 'FATAL error, unrecognized tag' refering to the very first Smarty tag in the document... What might be the problem? Thanks in advance! ???
  6. The problem is following. I have a column in MySQL of TEXT type. I put some text into it and the text consists of 2 paragrahs... However, when I try to output a text with php-script the paragraphs are gone and text is output as a single paragrahp. Using html-tag <br> is not a good idea, as I use (strip_tags) function. Is there any solution? Example (I input and would like to see as an output): Sun is shining. The weather is sweet. Actually outputs: Sun is shining. The weather is sweet.
  7. that was a silly mistake. shame on me. I corrected it, but the situation seemed to be the same Then I realized that I simply never assigned new value to Smarty engine. Thanks!
  8. I seem to be a bit in trouble with changing username or password of a logged in user. Everytime the user changes it, the username/password in session don't seem to be updated and when a user tries to go to any page he gets automatically logged out and has to log in again... How can I solve the problem? Here are both complete scripts, that I use: index.php [code]<? require_once('Smarty.class.php'); $smarty = new Smarty(); function checkUser($login, $pass) { $sql = mysql_query("SELECT id FROM admin WHERE login = '$login' AND password = '$pass'") or die(mysql_error()); if (mysql_num_rows($sql) == 1) { return true; } else {return false;} } function GetName($login){$result=mysql_query("SELECT name FROM admin WHERE login='$login'") or die(mysql_error()); return $name=mysql_result($result, 0, 'name'); } include_once 'data.php'; include_once 'security.php'; session_start(); $junk = array(',' , '/' ,"\\", '`' , ';' , '[' ,  ']' , '-', '_', '*', '&', '^', '#', '!', '~', '+', '(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '=', 'ь', 'х', 'д', 'ц'); if (isset($_POST['uid']) && isset($_POST['pwd'])){ $len = strlen($_POST['uid']); $_POST['uid'] = str_replace($junk, '', $_POST['uid']); $test = $_POST['uid']; if(strlen($test) != $len) { $smarty->assign('viga', 1);   } $passlen = strlen($_POST['pwd']); $_POST['pwd'] = str_replace($junk, '', $_POST['pwd']); $test2 = $_POST['pwd']; if(strlen($test2) != $passlen) { $smarty->assign('viga', 1);   }} if (isset($_POST['uid']) && isset($_POST['pwd'])) { $uid = security($_POST['uid']); $pwd = security($_POST['pwd']); if (checkUser($uid, $pwd)) { $_SESSION['auid'] = $uid; $_SESSION['apwd'] = $pwd; $smarty->assign('uid', $_SESSION['auid']); $smarty->assign('pwd', $_SESSION['apwd']); $name=GetName($_SESSION['auid']); $smarty->assign('name', $name); } else { $smarty->assign('viga', 1); }} elseif (isset($_SESSION['auid']) && isset($_SESSION['apwd'])) { $uid = $_SESSION['auid']; $pwd = $_SESSION['apwd']; $name=GetName($_SESSION['auid']); $smarty->assign('name', $name); if (checkUser($uid, $pwd)) { $smarty->assign('uid', $uid); $smarty->assign('pwd', $pwd); } else { $smarty->assign('viga', 1); } } if ((isset($_GET['logout'])) && ($_GET['logout']==1)) {         session_unset(); session_destroy(); header("Location:index.php"); } switch ($_GET['page']) { case 'change':   $smarty->assign('show', 'change');   break;   case 'addevent':   $smarty->assign('show', 'addevent');   break; default:   $smarty->assign('page', 1); } $smarty->assign('target', $_SERVER[PHP_SELF]); $smarty->display('back.tpl'); ?>[/code] change.php, that gets included into back.tpl when $_GET[page] == change [code]<? require_once('Smarty.class.php'); $smarty = new Smarty(); include_once 'security.php'; include_once 'data.php'; include_once 'checkuser2.php'; if(isset($_POST['olduid'])){ if($_POST['olduid']==NULL OR $_POST['uid1']==NULL OR $_POST['uid2']==NULL){ $smarty->assign('emptyuser', 1); } elseif($_POST['uid1']!=$_POST['uid2']){ $smarty->assign('umismatch', 1); } else{ $old=security($_POST['olduid']); if ($_SESSION['auid'] == $old){ $new=security($_POST['uid1']); if (checkUser2($new)==TRUE){ $result=mysql_query("UPDATE admin SET login='$new' WHERE login='$old'") or die(mysql_error()); $smarty->assign('uuspeh', 1); $_SESSION['auid']=$new; }else{$smarty->assign('exists', 1);} } else {$smarty->assign('wrongold', 1);} } } if(isset($_POST['oldpass'])){ if($_POST['oldpass']==NULL OR $_POST['pass1']==NULL OR $_POST['pass2']==NULL){ $smarty->assign('emptypass', 1); } elseif($_POST['pass1']!=$_POST['pass2']){ $smarty->assign('pmismatch', 1); } else{ $old=security($_POST['oldpass']); if ($_SESSION['apwd']==$old){ $new=security($_POST['pass1']); $result=mysql_query("UPDATE admin SET password='$new' WHERE password='$old' AND login='$_SESSION[auid]'") or die(mysql_error()); $smarty->assign('puspeh', 1); $_SESSION['apwd']=$new; } else {$smarty->assign('wrongoldp', 1);} } } $smarty->assign('target', $_SERVER[PHP_SELF]); $smarty->display('change.tpl'); ?>[/code]
  9. I have a little problem with logout in my script. There is a small piece of code responsible for that. [code]if ((isset($_GET['logout'])) && ($_GET['logout']==1)) {         session_unset(); session_destroy(); }[/code] And there is a link in the logged user interface with 'logout=1' in its URL.However, when I click this link, the user interface seems to stay. And it is only gone when I click it the second time. What might be the problem? Thank you in advance!
  10. well, that 's a decent solution... but isn't browser supposed not to reset these values?
  11. I am looking for some help. I realized that I do not know how to do it. I have a registration form with several fields. When user submits data, there is a script that controls data (whether username exists or not, first and second password match, etc...) If there is an error, it adds it to an array and displays the text(s) of error(s) on the same page where form is. However, all the data input into form fields is missing then and the user has to go through registration again... How do I do, so the data is saved, so the user has to repair only invalid fields and does not have to fill all the fields all over again. Is there any trick? Maybe the problem is with Smarty template engine that I am using? Thanks in advance!
×
×
  • 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.