Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: skubi pagalba

Parašė edgariuxXx· 2009 Vas. 23 20:02:35
#1

Stai vienas kodas:
Parse smiley bbcode into HTML images
function parsesmileys($message) {
   $smiley = array(
      "#\:\)#si" => "<img src='".IMAGES."smiley/smile.gif' alt='smiley'>",
      "#\;\)#si" => "<img src='".IMAGES."smiley/wink.gif' alt='smiley'>",
      "#\:\(#si" => "<img src='".IMAGES."smiley/sad.gif' alt='smiley'>",
      "#\:\|#si" => "<img src='".IMAGES."smiley/frown.gif' alt='smiley'>",
      "#\:o#si" => "<img src='".IMAGES."smiley/shock.gif' alt='smiley'>",
      "#\:p#si" => "<img src='".IMAGES."smiley/pfft.gif' alt='smiley'>",
      "#b\)#si" => "<img src='".IMAGES."smiley/cool.gif' alt='smiley'>",
      "#\:d#si" => "<img src='".IMAGES."smiley/grin.gif' alt='smiley'>",
      "#\:@#si" => "<img src='".IMAGES."smiley/angry.gif' alt='smiley'>"
   );
   foreach($smiley as $key=>$smiley_img) $message = preg_replace($key, $smiley_img, $message);
   return $message;
}

// Show smiley icons in comments, forum and other post pages
function displaysmileys($textarea) {
   $smiles = "";
   $smileys = array (
      ":)" => "smile.gif",
      ";)" => "wink.gif",
      ":|" => "frown.gif",
      ":(" => "sad.gif",
      ":o" => "shock.gif",
      ":p" => "pfft.gif",
      "B)" => "cool.gif",
      ":D" => "grin.gif",
      ":@" => "angry.gif"
   );
   foreach($smileys as $key=>$smiley) $smiles .= "<img src='".IMAGES."smiley/$smiley' alt='smiley' onClick=\"insertText('$textarea', '$key');\">\n";
   return $smiles;
ir as noriu ikelti naujas smiley ir nzn kur sita koda rasyti kad butu nauji smailai:
$result = dbquery("CREATE TABLE ".$db_prefix."smileys (
   smiley_id smallint(5) unsigned NOT NULL auto_increment,
   smiley_code varchar(50) NOT NULL,
   smiley_image varchar(100) NOT NULL,
   smiley_text varchar(100) NOT NULL,
   PRIMARY KEY  (smiley_id)
) TYPE=MyISAM;");
if ($result) {
   echo "Smiley table was created<br>";
   $smileys = array(
      array(":D", "biggrin.gif", "biggrin"),
      array("B)", "cool.gif", "cool"),
      array(":)", "happy.gif", "happy"),
      array(":@", "mad.gif", "mad"),
      array(":p", "razz.gif", "razz"),
      array(":(", "sad.gif", "sad"),
      array("*yes*", "yes.gif", "yes"),
      array("*no*", "no.gif", "no"),
      array("*dull*", "dull.gif", "dull"),
      array(":?", "confused.gif", "confused"),
      array(":o", "embarrassed.gif", "embarrassed"),
      array("*eek*", "eek.gif", "eek"),
      array("*rolleyes*", "rolleyes.gif", "rolleyes"),
      array(";)", "wink.gif", "wink"),
      array("*rofl*", "rofl.gif", "rofl"),
      array("o_O", "o_O.gif", "o_O"),
      array("*annoy*", "annoy.gif", "annoy"),
      array("*bye*", "bye.gif", "bye"),
      array("*clap*", "clap.gif", "clap"),
      array("*comfort*", "comfort.gif", "comfort"),
      array("*dog*", "dog.gif", "dog"),
      array("*flower*", "flower.gif", "flower"),
      array("*inlove*", "inlove.gif", "in love"),
      array("*kiss*", "kiss.gif", "kiss"),
      array("*pissed*", "pissed.gif", "pissed"),
      array("*pray*", "pray.gif", "pray"),
      array("*saycheese*", "saycheese.gif", "say cheese!"),
      array("*secret*", "secret.gif", "secret"),
      array("*sarcasm*", "sarcasm.gif", "sarcasm"),
      array("*stress*", "stress.gif", "stress"),
      array("*tup*", "tup.gif", "thumbs up"),
      array("*tdown*", "tdown.gif", "thumbs down"),
      array("*argue*", "argue.gif", "argue"),
      array("*blushing*", "blushing.gif", "blushing"),
      array("*bugs*", "bugs.gif", "bugs"),
      array("*finger*", "finger.gif", "middle finger"),
      array("*helpless*", "helpless.gif", "helpless"),
      array("*hilarious*", "hilarious.gif", "hilarious"),
      array("*hmm*", "hmm.gif", "hmm!"),
      array("*lol*", "lol.gif", "lol"),
      array("*music*", "music.gif", "music"),
      array("*neutral*", "neutral.gif", "neutral"),
      array("*realsad*", "realsad.gif", "real sad"),
      array("*shop*", "shop.gif", "shop"),
      array("*tongue*", "tongue.gif", "tongue"),
      array("*wait*", "wait.gif", "wait"),
      array("*yummy*", "yummy.gif", "yummy"),
      array("*zipit*", "zipit.gif", "zip it!")
   );
   for($i = 0; $i < count($smileys); $i ++) {
      $result = dbquery("INSERT INTO ".$db_prefix."smileys (smiley_code, smiley_image, smiley_text)
         VALUES ('".$smileys[$i][0]."', '".$smileys[$i][1]."', '".$smileys[$i][2]."')"
      );
   }
   if ($i > 0) { echo "$i smileys were added to the database<br>"; }
   $result = dbquery("INSERT INTO ".$db_prefix."admin (admin_rights, admin_image, admin_title,
      admin_link, admin_page) VALUES ('SM', 'smileys.gif', 'Smileys', 'smileys.php', 3)"
   );
   $result = dbquery("SELECT user_id, user_name, user_rights FROM ".$db_prefix."users WHERE user_level = '103'");
   while($data = dbarray($result)) {
      $rights_array = explode(".", $data['user_rights'].".SM");
      sort($rights_array);
      $rights = implode(".", $rights_array);
      $result2 = dbquery("UPDATE ".$db_prefix."users SET user_rights='$rights' WHERE user_id = '".$data['user_id']."'");
      if ($result2) { echo "<font color='red'><b>".$data['user_name']."</b></font> has been given access rights to the smiley admin<br>"; }
   }
}



padekite prasau c|

Redagavo MaFetas· 2009 Vas. 23 20:02:07