- 1
- 2
header('Content-Type: text/html; charset=utf-8\n\n');
session_commit();session_start();session_commit();session_start(); // магия, блять
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+193
header('Content-Type: text/html; charset=utf-8\n\n');
session_commit();session_start();session_commit();session_start(); // магия, блять
В PHP иногда возникает проблема с обновлением сессии (ну не успевает записать и всё тут), а сразу после обновления идёт вызов аяксом нового файла с header(...) и запросом этой же переменной сессии. Вот так вот решил кто-то (и кстати работает на ура):
+140.7
#include <stdio.h>
#include <string.h>
#define icon_no -
const char ICON_DEF[] = ".png";
const char ICON_NO[] = "-";
int main(int argc, char * argv[] ) {
char result[128];
char string[128];
strcpy(string,ICON_DEF);
char * ext_pnt = strrchr(string,'.');
if(!ext_pnt)
return 1;
char * ext = &ext_pnt[1];
int i;
printf("ext=%s\n",ext);
for ( i = 1; i< argc ; i++ ) {
char * arg = argv[i];
int extlen = strlen(ext);
if( strncmp(ext,arg,extlen) == 0 ) {
strcpy(result,&arg[extlen+1]);
} else {
strcpy(result,ICON_NO);
strcat(result,ext_pnt);
}
printf("arg[%d]=%s, result: %s\n", i, arg, result);
}
return 0;
}
−854
select * from Etbagent where id=555
слово хуй
+167.3
GLOBAL $_SERVER;
GLOBAL $_COOKIE;
.......
Вот переделывал код одного товариша, и так и не смог понять зачем вот эти строчки он добавлял в КАЖДЫЙ файл
+140.1
<?php
//Данные на базу
$lnk = mysql_connect('localhost', 'mysql_user', 'mysql_password')
or die ('Not connected : ' . mysql_error());
mysql_select_db('primecms_db', $lnk) or die ('Can\'t primecms_db foo : ' . mysql_error());
class insert{
var $pid, $alias, $text, $position, $status, $create_time, $modify_time;
}
function con_in($alias, $text_en, $text_ru, $text_descr){
$res = new insert;
$res->pid=1;
$res->alias=addslashes($alias);
$res->text='<p>'.addslashes($text_en).'</p>\r\n<p>'.addslashes($text_ru).'</p>\r\n<p>'.addslashes($text_descr).'</p>';
$res->position=0;
$res->status=1;
$res->create_time=time();
$res->modify_time=time();
return $res;
}
if ($_POST['send']){
$con = con_in($_POST['alias'],$_POST['text_en'],$_POST['text_ru'],$_POST['text_descr']);
mysql_query("INSERT INTO e118_glossary_items (`id`, `pid`, `alias`, `text`, `position`, `status`, `create_time`, `modify_time`) VALUES (".$con->pid.",'".$con->alias."','".$con->text."',".$con->position.",".$con->status.",".$con->create_time.",".$con->modify_time.")");
}
?>
<form name="" action="" method="post">
Alias<input name="alias" size=30 type="text" value=""><br />
text_en<input name="text_en" size=30 type="text" value=""><br />
text_ru<input name="text_ru" size=30 type="text" value=""><br />
text decr<textarea name="text_descr" rows=7 cols=50 wrap="off"></textarea><br />
<input type="submit" value="Send" name="send"><br />
</form>
не забываем править
//Данные на базу
+152
<?php
mysql_connect ($server, $username, $password);
//Данные на базу
$lnk = mysql_connect('localhost', 'mysql_user', 'mysql_password')
or die ('Not connected : ' . mysql_error());
mysql_select_db('primecms_db', $lnk) or die ('Can\'t primecms_db foo : ' . mysql_error());
class insert{
var $pid, $alias, $text, $position, $status, $create_time, $modify_time;
}
function con_in($pid, $alias, $text_en, $text_ru, $text_descr, $position, $status, $create_time, $modify_time){
$res = new insert;
$res->pid=$pid;
$res->alias=addslashes($alias);
$res->text='<p>'.addslashes($text_en).'</p>\r\n<p>'.addslashes($text_ru).'</p>\r\n<p>'.addslashes($text_descr).'</p>';
$res->position=$position;
$res->status=$status;
$res->create_time=$create_time;
$res->modify_time=$modify_time;
return $res;
}
if ($_POST['send']){
$con = con_in($_POST['pid'],$_POST['alias'],$_POST['text_en'],$_POST['text_ru'],$_POST['text_descr'],$_POST['position'],$_POST['status'],$_POST['create_time'],$_POST['modify_time']);
mysql_query("INSERT INTO e118_glossary_items (`id`, `pid`, `alias`, `text`, `position`, `status`, `create_time`, `modify_time`) VALUES (".$con->pid.",".$con->alias.",".$con->text.",".$con->position.",".$con->status.",".$con->create_time.",".$con->modify_time.")");
}
?>
<form name="" action="" method="post">
Pid<input name="pid" size=30 type="text" value=""><br />
Allias<input name="allias" size=30 type="text" value=""><br />
text_en<input name="text_en" size=30 type="text" value=""><br />
text_ru<input name="text_ru" size=30 type="text" value=""><br />
text decr<textarea name="text_descr" rows=7 cols=50 wrap="off"></textarea><br />
position<input name="position" size=30 type="text" value=""><br />
status<input name="status" size=30 type="text" value=""> <br />
create_time<input name="create_time" size=30 type="text" value=""><br />
modify_time<input name="modify_time" size=30 type="text" value=""><br />
<input type="submit" value="Send" name="send"><br />
</form>
для инсёрта
назови insert.php
подправь //Данные на базу
+292.2
...
cmp eax, 0
ja l1
jna l2
l2:
...
сферический говнокод в ваккуме
+153
//заполнение рандомными числами двух первых массивов и вывод их на экран:
for (i=0;i<n;i++){
for (j=0;j<m;j++){
randomize();
A[i][j]=random(100)-50;
printf("A[%d][%d]:",i,j);
printf("%d",A[i][j]);
}}
for (i1=0;i1<n1;i1++){
for (j1=0;j1<m1;j1++){
randomize();
B[i1][j1]=random(100)-50;
printf("B[%d][%d]:",i1,j1);
printf("%d",B[i1][j1]);
}}
//сложение матриц:
for (i=0;i<n;i++){
for (j=0;j<m;j++){
for (i1=0;i1<n1;i1++){
for (j1=0;j1<m1;j1++){
C[i2][j2]=A[i][j]+B[i1][j1]
}}}}
//а описание одних только счетчиков выглядит так:
int i,j,i1,j1,i2,j2,i3,j3,i4,j4,is,js,ir,jr;
Восстановлено по памяти из незаконченной лабы одной программистки-первокурсницы
+153
foreach (DirectoryInfo dir in dirs.GetDirectories())
{
stream.Write(new byte[] { (byte)NetworkMessage.MakeDir }, 0, 1);//crea\te folder{16}
stream.Read(new byte[1],0, 1);
stream.Write(BitConverter.GetBytes(Encoding.UTF8.GetBytes(SubFolder.Replace('\\', '/') + dir.Name.Replace('\\', '/')).Length),0, 4);
stream.Write(Encoding.UTF8.GetBytes(SubFolder.Replace('\\', '/') + dir.Name.Replace('\\', '/')),0, Encoding.UTF8.GetBytes(SubFolder.Replace('\\', '/') + dir.Name.Replace('\\', '/')).Length);
//send folder name
stream.Read(new byte[1], 0, 1);//Ok
}
Краткость-сестра таланта =)))
+154
package com.photoholding.processimage.eugene;
import java.awt.Point;
import java.awt.Rectangle;
import magick.ImageInfo;
import magick.MagickException;
import magick.MagickImage;
public class ProcessA {
private MagickImage img;
private String text;
private String imageOrigin;
private String fout;
private String fmount;
private final String tmpImg = "tmpIM.jpg";
private final String tmpMnt = "tmpMounted.jpg";
private final int width = 1607;
private final int height = 1205;
public ProcessA( String txt, String fin, String fout, String fmount ){
if( txt.length() > 52 ){
System.out.println( "error: text string more than 52" );
System.exit(0);
}
this.text = txt;
this.img = getImage( fin );
this.imageOrigin = fin;
this.fmount = fmount;
this.fout = fout;
}
private MagickImage getImage( String fin2 ) {
MagickImage im = null;
try {
im = new MagickImage( new ImageInfo( fin2 ) );
} catch ( MagickException e ) {
e.printStackTrace();
return null;
}
return im;
}
public boolean doProcess(){
try {
scaleGenerally();
annotateMounted();
montage();
} catch ( Exception e ) {
e.printStackTrace();
return false;
}
return true;
}
private void montage() throws Exception {
MagickProcessing mp = new MagickProcessing();
mp.montage( tmpMnt, tmpImg, fout );
}
private void annotateMounted() throws Exception {
MagickProcessing mp = new MagickProcessing();
mp.annotateImage( text, new Point( 115, 1195 - ( 598 - ( ( text.length() / 2 ) * 23 ) ) ), fmount, tmpMnt );
}
protected boolean scaleGenerally() throws Exception {
int h = img.getDimension().height;
int w = img.getDimension().width;
MagickProcessing mp = new MagickProcessing();
if( h > w ){
if ( !mp.rotateANDscale( "1607x", imageOrigin, tmpImg )) return false;
img = getImage( tmpImg );
h = img.getDimension().height;
w = img.getDimension().width;
if( h < height ){
if( !mp.rotateANDscale( "x1205", imageOrigin, tmpImg )) return false;
img = getImage( tmpImg );
h = img.getDimension().height;
w = img.getDimension().width;
}
if( !mp.crop( new Rectangle( ( w - width ) / 2, 0, 1607, 1205 ), tmpImg, tmpImg )) return false;
} else {
if( !mp.scaleImage( "1607x", imageOrigin, tmpImg ) ) return false;
img = getImage( tmpImg );
h = img.getDimension().height;
w = img.getDimension().width;
if( h < height ){
if( !mp.scaleImage( "x1205", imageOrigin, tmpImg ) ) return false;
if( !mp.crop( new Rectangle( ( w - width ) / 2, 0, 1607, 1205 ), tmpImg, tmpImg ) ) return false;
} else if( h > height ){
if( !mp.crop( new Rectangle( 0, (int)( h - height ) / 2, width, height ), tmpImg, tmpImg )) return false;
}
}
return true;
}
}
постановка задачи - нужен метод для вращения изображений