Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - alex

Pages: 1 [2] 3 4 ... 6
16
php Basic Functions / PHP Array
« on: November 19, 2010, 12:56:33 PM »
Code: [Select]
<?php 
$acvalue 
= array(=> 'value1',=> 'value2',=> 'value3');
echo
"<pre>";
print_r ($acvalue);
echo
"</pre>";
?>


Output:



17
E-Cards / Re: Install
« on: October 20, 2010, 04:31:06 AM »
 :)

18
MySQL / Re: RSS, MYSQL & Smarty
« on: September 11, 2010, 04:57:42 PM »
Mysql Code

Code: [Select]
CREATE TABLE `news` (
  `id` int(11) NOT NULL auto_increment,
  `title` text collate utf8_unicode_ci,
  `text` text collate utf8_unicode_ci,
  `date` datetime default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;


INSERT INTO `news` VALUES (1, 'News1', 'Description1', '2010-09-09 16:52:46');
INSERT INTO `news` VALUES (2, 'News2', 'Description2', '2010-09-09 16:54:19');
INSERT INTO `news` VALUES (3, 'News3', 'Description3', '2010-09-09 16:55:11');

19
MySQL / RSS, MYSQL & Smarty
« on: September 11, 2010, 04:49:17 PM »
config.php

Code: [Select]
<?php 
$dbhost 
'localhost';
$dbusername 'root';
$dbpassword 'mydbpass';
$dbname 'test';
$conn=mysql_connect($dbhost$dbusername$dbpassword);
if(!
$conn) :
   die(
'Could not connect: ' mysql_error());
endif;
$db=mysql_select_db($dbname$conn);
if(!
$db) :
   die (
'Can't connect to database :  . mysql_error());
endif;
?>


rss.php

Code: [Select]
<?php
//database connection
include_once('config.php');
include(
'smarty/Smarty.class.php'); 
$smarty = new smarty(); 
$smarty->template_dir 'templates'
$smarty->compile_dir 'templates_c'
$smarty->config_dir 'config'
$smarty->cache_dir 'cache'
?>

<?php header('Content-type: application/rss+xml'); ?>
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; ?>
<?php
$res 
mysql_query("SELECT * FROM news ORDER by id DESC LIMIT 20"
or die(
mysql_error()); 
while(
$row mysql_fetch_array($res)){
$value[] = $row;
}
$smarty->assign('news'$value);
$smarty->caching 1;
$smarty->display('rss.tpl');
?>


templates/rss.tpl

Code: [Select]
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Example.com</title>
<description>Example WebSite</description>
<link>http://www.example.com</link>
{section name=news loop=$news}
<item>
<title>{$news[news].title|stripslashes|truncate:50} :: Example.com</title>
<description>{$news[news].text|stripslashes|escape:'html'}</description>
<link>http://www.example.com/page.php?id={$news[news].id}</link>
<guid>www.example.com/page.php?id={$news[news].id}</guid>
<pubDate>{$news[news].date|date_format:"%a, %e %b %Y %H:%M:%S"} GMT</pubDate>
</item>
{/section}
</channel>
</rss>
:)

20
LinkBase L.1.0 / Re: Problem with outgoing links
« on: August 25, 2010, 12:20:46 PM »
Code: [Select]
<?php
require_once('admin/config.php');
$id $_GET['id'];
$result mysql_query("SELECT linkid, text, linkurl, hits FROM oslink WHERE linkid='$id' ")
or die(
mysql_error());  
while(
$myrow mysql_fetch_assoc($result))
{
$resulty mysql_query("UPDATE oslink SET hits=hits+'1' WHERE linkid='$id'"
or die(
mysql_error());  
$redirect $myrow['linkurl'];
?>

<SCRIPT LANGUAGE="JavaScript">
redirTime = "50";
redirURL = "<?php echo $redirect ?>";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
//  End -->
</script>
<BODY onLoad="redirTimer()">
<?php
}
?>
:) :) :) :) :)

21
LinkBase L.1.0 / Re: Problem with outgoing links
« on: August 25, 2010, 03:56:11 AM »
Quote
when i visit a page over the script it goes but when i visit a page over the script twice or another link from the page it doesnt work... after a while i wait it goes again.. one visit is ok but the second visit is not going...

out.php
 :) :)
Code: [Select]
<?php

require_once('admin/config.php');
$id $_GET['id'];
session_start();
if (!isset(
$_SESSION["jumps"]))
$_SESSION["jumps"] = 0;
$_SESSION["jumps"] = $_SESSION["jumps"] + 1;
if (
$_SESSION["jumps"] > 1)
{
//echo "text text";
}
else
{
$result mysql_query("SELECT linkid, text, linkurl, hits FROM oslink WHERE linkid='$id' ")
or die(
mysql_error());  
while(
$myrow mysql_fetch_assoc($result))
{
$resulty mysql_query("UPDATE oslink SET hits=hits+'1' WHERE linkid='$id'"
or die(
mysql_error());  
$redirect $myrow['linkurl'];
?>

<SCRIPT LANGUAGE="JavaScript">
redirTime = "50";
redirURL = "<?php echo $redirect ?>";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
//  End -->
</script>
<BODY onLoad="redirTimer()">
<?php
}
}
?>

22
LinkBase L.1.0 / Re: resett, delet all links at once
« on: August 02, 2010, 04:18:03 AM »
.. second if you put a long group name it is out of the box, any way to fix this?

Find the line:(templates/default/style.css)

Code: [Select]
#aanav{BACKGROUND:#eee;height:22px;width:159px;line-height:22px;list-style:url(images/back.png);text-align:center;border:1px solid #ccc;-moz-border-radius-topleft:12px 12px;-moz-border-radius-topright:12px 12px;-moz-border-radius-bottomleft:12px 12px;-moz-border-radius-bottomright:12px 12px;-webkit-border-top-right-radius:12px;-webkit-border-top-left-radius:12px;-webkit-border-bottom-right-radius:12px;-webkit-border-bottom-left-radius:12px;text-transform:uppercase;}
Replace with:

Code: [Select]
#aanav{BACKGROUND:#eee;width:159px;line-height:22px;list-style:url(images/back.png);text-align:center;border:1px solid #ccc;-moz-border-radius-topleft:12px 12px;-moz-border-radius-topright:12px 12px;-moz-border-radius-bottomleft:12px 12px;-moz-border-radius-bottomright:12px 12px;-webkit-border-top-right-radius:12px;-webkit-border-top-left-radius:12px;-webkit-border-bottom-right-radius:12px;-webkit-border-bottom-left-radius:12px;text-transform:uppercase;}

23
Free PHP Scripts / Re: Guestbook Admin Page
« on: August 01, 2010, 12:52:57 AM »
http://phpform.net/board/index.php/topic,348.0.html  :)

24
Free PHP Scripts / GuestBook 20
« on: August 01, 2010, 12:51:15 AM »
1. Unzip
2. Upload guestbook folder


Quote
http://www.example.com/guestbook/

3. Upload fontf folder



Quote
http://www.example.com/fontf/

4. Upload files book.php, captchas.php, send.php, wordsk.php



Quote
http://www.example.com/book.php...

5. chmod 666 sett.php

6. Follow the instructions


Quote
http://www.example.com/guestbook/menage/install.php

7. chmod 644 config.php

8. PHP Code to display guestbook:



Quote
<IFRAME style="border:1px solid #ffffff" SRC="/book.php" WIDTH=595 HEIGHT=700 BORDER=1 SOLID></iframe>

To use the "GuestBook 20." script completely free,
the "powered by" link at the bottom of the pages must stay intact.


25
MySQL / Re: Creating dynamic Websites with PHP, MySQL and Smarty
« on: July 20, 2010, 01:48:21 PM »

26
MySQL / Re: Creating dynamic Websites with PHP, MySQL and Smarty
« on: July 20, 2010, 01:45:27 PM »
webpage.php
Code: [Select]
<?php
////make a MySQL connection
include('config.php');
// smarty configuration
include('Smarty.class.php'); 
$smarty = new smarty(); 
$smarty->template_dir 'templates'
$smarty->compile_dir 'templates_c'
$smarty->cache_dir 'cache';
//get ID from URL
$id $_GET['id'];
//get linkid, text, linkurl from the page table
//..or..*=select everything from the table page
$result mysql_query("SELECT linkid, text, linkurl 
FROM page WHERE linkid='$id' "
)
or die(
mysql_error()); 
while(
$myrow mysql_fetch_assoc($result))
{
$values[] = $myrow;
}
$smarty->assign('page'$values);
$smarty->caching 1;
//$REQUEST_URI will create a separate cache file 
//for each unique URL when you call webpage.tpl.
$smarty->display('webpage.tpl',$REQUEST_URI);
?>

templates/webpage.tpl

Code: [Select]
{section name=page loop=$page}

<head><title>{$page[page].text}</title></head>

<h1>{$page[page].text}</h1>

<a href="{$page[page].linkurl}">{$page[page].text}</a>
 
{/section}

27
MySQL / Creating dynamic Websites with PHP, MySQL and Smarty
« on: July 20, 2010, 01:44:13 PM »
config.php

Code: [Select]
<?php 
//MySQL Configuration
//DB Host (Normally 'localhost')
$dbhost 'localhost';
//DB Database Username
$dbusername 'root';
//DB Database User Password
$dbpassword 'mypassword';
//DB Database Name
$dbname 'mydbname';
//mysql_connect function
$conn=mysql_connect($dbhost$dbusername$dbpassword);
if(!
$conn) :
   die(
'Could not connect: ' mysql_error());
endif;
$db=mysql_select_db($dbname$conn);
if(!
$db) :
   die (
'Cant connect to database : ' mysql_error());
endif;
?>

install.php
Code: [Select]
<?php
//make a MySQL connection
include('config.php');
//create a MySQL table in the selected database
mysql_query("CREATE TABLE `page` (
  `linkid` int(11) NOT NULL auto_increment,
  `text` text collate utf8_unicode_ci,
  `linkurl` text collate utf8_unicode_ci,
    PRIMARY KEY  (`linkid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 
COLLATE=utf8_unicode_ci AUTO_INCREMENT=1"
)
or die(
mysql_error());
?>

index.php
Code: [Select]
<title>Index Page</title>
<center><h2>INDEX</h2></center><BR>
<?php
//make a MySQL connection
include('config.php');
echo 
"&nbsp;<a href=\"insert.php\">INSERT PHP</a><br>";
//get all the data from the page table
//*=select everything from the table page
$result mysql_query("SELECT * FROM page"
or die(
mysql_error()); 
while(
$link=mysql_fetch_array($result)){
//echo (display) a link using $link[linkid]
echo "&nbsp;<a href=\"webpage.php?id=$link[linkid]\">Web Page 1</a><br>";
}
?>

insert.php

Code: [Select]
<title>Insert Page</title>
<center><h2>INSERT PAGE</h2></center><br>
<a href="index.php">INDEX PAGE</a>
<?php
//make a MySQL connection
include('config.php');
//to check if a submit button was clicked, use this...
if(isset($_POST['submit']))
{
$text $_POST['text'];
$linkurl $_POST['linkurl'];
//the INSERT INTO statement is used 
//to add new records to a database table
mysql_query("INSERT INTO page (text,linkurl)
VALUES ('$text','$linkurl')"
)
or die(
mysql_error());  
}else{
?>

<form method="post" action="insert.php">
<TABLE><TR><TD>
Title:
</TD>
<TD>
<input name="text" size="60" maxlength="255">
</TD></TR>
<TR><TD>
URL:
</TD>
<TD>
<input name="linkurl" size="60" maxlength="255">
</TD></TR>
<TR><TD>
<input type="submit" name="submit" value="submit">

</TD></TR></TABLE>
</form>
<?php
}
?>

28
Free PHP Scripts / Re: Shoutbox 1.1. PHP Script
« on: June 06, 2010, 10:31:34 PM »
when i install i get a sql error on line 6 saying;
my database is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in BLAH BLAH BLAH on line 6

If you get the following error, it means that mysqld has received many connect requests from the host 'host_name' that have been interrupted in the middle: http://dev.mysql.com/doc/refman/4.1/en/blocked-host.html

29
LinkBase 2.0. / Re: post comments without register
« on: May 31, 2010, 05:13:38 AM »
this feature will be included in next version :)

30
Source Code / Re: php mail script not working
« on: May 14, 2010, 01:56:16 PM »
Code: [Select]
$to      = "customer_support@1900tr.com";
$subject = $_REQUEST["subject"];
$body = $_REQUEST["body"];
$email = $_REQUEST["email"];
$name = $_REQUEST["name"];

$dodgy_strings = array(
                "content-type:"
                ,"mime-version:"
                ,"multipart/mixed"
                ,"bcc:"
);

function is_valid_email($email) {
  return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email);
}

function contains_bad_str($str_to_test) {
  $bad_strings = array(
                "content-type:"
                ,"mime-version:"
                ,"multipart/mixed"
,"Content-Transfer-Encoding:"
                ,"bcc:"
,"cc:"
,"to:"
  );
 
  foreach($bad_strings as $bad_string) {
    if(eregi($bad_string, strtolower($str_to_test))) {
      echo "$bad_string found. Suspected injection attempt - mail not being sent.";
      exit;
    }
  }
}

function contains_newlines($str_to_test) {
   if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $str_to_test) != 0) {
     echo "newline found in $str_to_test. Suspected injection attempt - mail not being sent.";
     exit;
   }
}

if($_SERVER['REQUEST_METHOD'] != "POST"){
   echo("Unauthorized attempt to access page.");
   exit;
}

if (!is_valid_email($email)) {
  echo 'Invalid email submitted - mail not being sent.';
  exit;
}

contains_bad_str($email);
contains_bad_str($subject);
contains_bad_str($body);//replace body with $body

contains_newlines($email);
contains_newlines($subject);

$body = $body . " From: " . $name;
$headers='MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n";
$headers .= "From: $email" . "\r\n";
mail ($to, $subject, $body, $headers);
echo "Thanks for submitting.";

Pages: 1 [2] 3 4 ... 6